diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2017-02-21 23:47:34 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-22 10:12:15 -0800 |
commit | 068f85e31311f521adffbcbf96f6583206d77b7d (patch) | |
tree | add0d9ed1866b3d03e4641b1fc8ae6ca3b519478 /cache.h | |
parent | 43bc3b6ceeb4cf3ed13741ffe02ed432e743fba5 (diff) | |
download | git-068f85e31311f521adffbcbf96f6583206d77b7d.tar.gz |
sha1_file: introduce an nth_packed_object_oid function
There are places in the code where we would like to provide a struct
object_id *, yet read the hash directly from the pack. Provide an
nth_packed_object_oid function that is similar to the
nth_packed_object_sha1 function.
In order to avoid a potentially invalid cast, nth_packed_object_oid
provides a variable into which to store the value, which it returns on
success; on error, it returns NULL, as nth_packed_object_sha1 does.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r-- | cache.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1608,6 +1608,12 @@ extern void check_pack_index_ptr(const struct packed_git *p, const void *ptr); * error. */ extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t n); +/* + * Like nth_packed_object_sha1, but write the data into the object specified by + * the the first argument. Returns the first argument on success, and NULL on + * error. + */ +extern const struct object_id *nth_packed_object_oid(struct object_id *, struct packed_git *, uint32_t n); /* * Return the offset of the nth object within the specified packfile. |