Commit adc0327a by Vicent Marti

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>
parent 58519018
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment