diff options
| author | Vicent Marti <tanoku@gmail.com> | 2010-10-29 00:44:15 +0300 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2010-10-29 00:44:15 +0300 |
| commit | adc0327ab308696650b62b2a8ded75f788f7b297 (patch) | |
| tree | 82d3e0562a36bdc9d8c7e7fd4a93c315b43f4567 /src/git | |
| parent | 585190183b47dc991605abcfbe3afb57220a0f29 (diff) | |
| download | libgit2-adc0327ab308696650b62b2a8ded75f788f7b297.tar.gz | |
Add git_odb_read_header method to the ODB
As requested, git_odb_read_header looks up an object on the ODB, but loads
only the header information (type & size) without loading any of the
actual file contents in memory.
It is significantly faster than doing a git_odb_read if you only need an
object's information and not its contents.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/git')
| -rw-r--r-- | src/git/odb.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/git/odb.h b/src/git/odb.h index a132346c6..b4812424c 100644 --- a/src/git/odb.h +++ b/src/git/odb.h @@ -69,6 +69,25 @@ typedef struct { GIT_EXTERN(int) git_odb_read(git_rawobj *out, git_odb *db, const git_oid *id); /** + * Read the header of an object from the database, without + * reading its full contents. + * + * Only the 'type' and 'len' fields of the git_rawobj structure + * are filled. The 'data' pointer will always be NULL. + * + * The raw object pointed by 'out' doesn't need to be manually + * closed with git_obj_close(). + * + * @param out object descriptor to populate upon reading. + * @param db database to search for the object in. + * @param id identity of the object to read. + * @return + * - GIT_SUCCESS if the object was read; + * - GIT_ENOTFOUND if the object is not in the database. + */ +GIT_EXTERN(int) git_odb_read_header(git_rawobj *out, git_odb *db, const git_oid *id); + +/** * Read an object from the database using only pack files. * * If GIT_ENOTFOUND then out->data is set to NULL. |
