sha1_object_info_extended: provide delta base sha1s
commit5d642e75069334944fcc795a80cf04749dd12857
authorJeff King <peff@peff.net>
Sat, 21 Dec 2013 14:24:20 +0000 (21 09:24 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 Dec 2013 19:53:32 +0000 (26 11:53 -0800)
treeaf2396187952817f081170e8b8deff9c051de041
parent7794a680e63a2a11b73cb1194653662f2769a792
sha1_object_info_extended: provide delta base sha1s

A caller of sha1_object_info_extended technically has enough
information to determine the base sha1 from the results of
the call. It knows the pack, offset, and delta type of the
object, which is sufficient to find the base.

However, the functions to do so are not publicly available,
and the code itself is intimate enough with the pack details
that it should be abstracted away. We could add a public
helper to allow callers to query the delta base separately,
but it is simpler and slightly more efficient to optionally
grab it along with the rest of the object_info data.

For cases where the object is not stored as a delta, we
write the null sha1 into the query field. A careful caller
could check "oi.whence == OI_PACKED && oi.u.packed.is_delta"
before looking at the base sha1, but using the null sha1
provides a simple alternative (and gives a better sanity
check for a non-careful caller than simply returning random
bytes).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
sha1_file.c