summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 7dadd04..9ae98c8 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;
}