summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-09-19 15:41:10 -0400
committerJunio C Hamano <gitster@pobox.com>2017-09-20 11:33:29 +0900
commitf0f7bebef73346a12aa1e22cf5264cbc241ab069 (patch)
tree3e21bd23cfcad936a37310265420f0db25261b72 /sha1_file.c
parent0db625f5d69c9d1fb6ace137fc755887aef3049e (diff)
downloadgit-f0f7bebef73346a12aa1e22cf5264cbc241ab069.tar.gz
read_info_alternates: warn on non-trivial errors
When we fail to open $GIT_DIR/info/alternates, we silently assume there are no alternates. This is the right thing to do for ENOENT, but not for other errors. A hard error is probably overkill here. If we fail to read an alternates file then either we'll complete our operation anyway, or we'll fail to find some needed object. Either way, a warning is good idea. And we already have a helper function to handle this pattern; let's just call warn_on_fopen_error(). Note that technically the errno from strbuf_read_file() might be from a read() error, not open(). But since read() would never return ENOENT or ENOTDIR, and since it produces a generic "unable to access" error, it's suitable for handling errors from either. Signed-off-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.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index a913865df8..d65ca43245 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -456,6 +456,7 @@ static void read_info_alternates(const char * relative_base, int depth)
path = xstrfmt("%s/info/alternates", relative_base);
if (strbuf_read_file(&buf, path, 1024) < 0) {
+ warn_on_fopen_errors(path);
free(path);
return;
}