diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-11-06 10:00:57 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-11-06 11:03:33 -0800 |
commit | 4ef8d1dd03d3b8adf81b4b81b2231128e3591f36 (patch) | |
tree | 102db9c3334ecb998e7b7d3a64ca711a6df4b17e /sha1_file.c | |
parent | d619cfc7490481652833dff820e04263869c8861 (diff) | |
download | git-4ef8d1dd03d3b8adf81b4b81b2231128e3591f36.tar.gz |
sha1_loose_object_info(): do not return success on missing objectsb/sha1-loose-object-info-check-existence
Since 052fe5ea (sha1_loose_object_info: make type lookup optional,
2013-07-12), sha1_loose_object_info() returns happily without
checking if the object in question exists, which is not what the the
caller sha1_object_info_extended() expects; the caller does not even
bother checking the existence of the object itself.
Noticed-by: Sven Brauch <svenbrauch@googlemail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c index 613839db54..d17315d72b 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2413,15 +2413,18 @@ static int sha1_loose_object_info(const unsigned char *sha1, /* * If we don't care about type or size, then we don't - * need to look inside the object at all. + * need to look inside the object at all. Note that we + * do not optimize out the stat call, even if the + * caller doesn't care about the disk-size, since our + * return value implicitly indicates whether the + * object even exists. */ if (!oi->typep && !oi->sizep) { - if (oi->disk_sizep) { - struct stat st; - if (stat_sha1_file(sha1, &st) < 0) - return -1; + struct stat st; + if (stat_sha1_file(sha1, &st) < 0) + return -1; + if (oi->disk_sizep) *oi->disk_sizep = st.st_size; - } return 0; } |