summaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-05-22 16:17:51 +0200
committerJunio C Hamano <gitster@pobox.com>2017-05-23 14:29:56 +0900
commit89c571da56a1e84fe12308f727fac0e82c1d5be6 (patch)
tree061b4d17ad48789c478469cb75d24e7440cc9b6b /refs
parent099a912a279415dd27716ee5de07ff347bfc49da (diff)
downloadgit-89c571da56a1e84fe12308f727fac0e82c1d5be6.tar.gz
read_packed_refs(): report unexpected fopen() failures
The old code ignored any errors encountered when trying to fopen the "packed-refs" file, treating all such failures as if the file didn't exist. But it could be that there is some other error opening the file (e.g., permissions problems), and we don't want to silently ignore such problems. So report any failures that are not due to ENOENT. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r--refs/files-backend.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index b4fa745cd7..dbfd03f989 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -251,8 +251,18 @@ static struct packed_ref_cache *read_packed_refs(const char *packed_refs_file)
packed_refs->cache->root->flag &= ~REF_INCOMPLETE;
f = fopen(packed_refs_file, "r");
- if (!f)
- return packed_refs;
+ if (!f) {
+ if (errno == ENOENT) {
+ /*
+ * This is OK; it just means that no
+ * "packed-refs" file has been written yet,
+ * which is equivalent to it being empty.
+ */
+ return packed_refs;
+ } else {
+ die_errno("couldn't read %s", packed_refs_file);
+ }
+ }
stat_validity_update(&packed_refs->validity, fileno(f));