diff options
author | Vicent Marti <tanoku@gmail.com> | 2012-11-17 19:54:47 -0800 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2012-11-27 13:18:27 -0800 |
commit | cfbe4be3fb639d96587974794fe437ace0c383c4 (patch) | |
tree | 1dcc1a4462075a7832d4cb853634af00fb78e7b1 /include/git2/blob.h | |
parent | 2508cc66eb91597b12dc19721d9cea1f06e72107 (diff) | |
download | libgit2-cfbe4be3fb639d96587974794fe437ace0c383c4.tar.gz |
More external API cleanup
Conflicts:
src/branch.c
tests-clar/refs/branches/create.c
Diffstat (limited to 'include/git2/blob.h')
-rw-r--r-- | include/git2/blob.h | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/include/git2/blob.h b/include/git2/blob.h index f0719f15d..a68c78b5a 100644 --- a/include/git2/blob.h +++ b/include/git2/blob.h @@ -68,6 +68,17 @@ GIT_INLINE(void) git_blob_free(git_blob *blob) git_object_free((git_object *) blob); } +/** + * Get the id of a blob. + * + * @param blob a previously loaded blob. + * @return SHA1 hash for this blob. + */ +GIT_INLINE(const git_oid *) git_blob_id(const git_blob *blob) +{ + return git_object_id((const git_object *)blob); +} + /** * Get a read-only buffer with the raw content of a blob. @@ -88,32 +99,35 @@ GIT_EXTERN(const void *) git_blob_rawcontent(git_blob *blob); * @param blob pointer to the blob * @return size on bytes */ -GIT_EXTERN(size_t) git_blob_rawsize(git_blob *blob); +GIT_EXTERN(git_off_t) git_blob_rawsize(git_blob *blob); /** * Read a file from the working folder of a repository * and write it to the Object Database as a loose blob * - * @param oid return the id of the written blob + * @param id return the id of the written blob * @param repo repository where the blob will be written. * this repository cannot be bare - * @param path file from which the blob will be created, + * @param relative_path file from which the blob will be created, * relative to the repository's working dir * @return 0 or an error code */ -GIT_EXTERN(int) git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path); +GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path); /** * Read a file from the filesystem and write its content * to the Object Database as a loose blob * - * @param oid return the id of the written blob + * @param id return the id of the written blob * @param repo repository where the blob will be written. * this repository can be bare or not * @param path file from which the blob will be created * @return 0 or an error code */ -GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, const char *path); +GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path); + + +typedef int (*git_blob_chunk_cb)(char *content, size_t max_length, void *payload); /** * Write a loose blob to the Object Database from a @@ -141,7 +155,7 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, con * - When an error occurs, the callback should return -1. * * - * @param oid Return the id of the written blob + * @param id Return the id of the written blob * * @param repo repository where the blob will be written. * This repository can be bare or not. @@ -152,10 +166,10 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, con * @return GIT_SUCCESS or an error code */ GIT_EXTERN(int) git_blob_create_fromchunks( - git_oid *oid, + git_oid *id, git_repository *repo, const char *hintpath, - int (*source_cb)(char *content, size_t max_length, void *payload), + git_blob_chunk_cb callback, void *payload); /** |