diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-12-17 11:31:18 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-12-17 11:31:18 -0800 |
commit | 66c24cd8a4b8db93b5fee81f144d6411ac7e5391 (patch) | |
tree | f41dabc14c1dd81ec21c27928ea6f57e9ee03cca /sha1_file.c | |
parent | c8b928d7700b581118a7a1beb957184fcbe57d06 (diff) | |
parent | 4ef8d1dd03d3b8adf81b4b81b2231128e3591f36 (diff) | |
download | git-66c24cd8a4b8db93b5fee81f144d6411ac7e5391.tar.gz |
Merge branch 'sb/sha1-loose-object-info-check-existence' into maint
"git cat-file --batch-check=ok" did not check the existence of the
named object.
* sb/sha1-loose-object-info-check-existence:
sha1_loose_object_info(): do not return success on missing object
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 7dadd04cb7..9ae98c852c 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2483,15 +2483,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; } |