[PATCH 07/15] remote.c: report error on failure to fopen()
- Date: Thu, 20 Apr 2017 18:26:01 +0700
- From: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
- Subject: [PATCH 07/15] remote.c: report error on failure to fopen()
There's plenty of error() in this code to safely assume --quiet is not a
concern.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
remote.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/remote.c b/remote.c
index 801137c72e..8ccc1e7b99 100644
--- a/remote.c
+++ b/remote.c
@@ -253,8 +253,12 @@ static void read_remotes_file(struct remote *remote)
struct strbuf buf = STRBUF_INIT;
FILE *f = fopen(git_path("remotes/%s", remote->name), "r");
- if (!f)
+ if (!f) {
+ if (errno != ENOENT)
+ warn_on_inaccessible(git_path("remotes/%s",
+ remote->name));
return;
+ }
remote->configured_in_repo = 1;
remote->origin = REMOTE_REMOTES;
while (strbuf_getline(&buf, f) != EOF) {
@@ -279,8 +283,12 @@ static void read_branches_file(struct remote *remote)
struct strbuf buf = STRBUF_INIT;
FILE *f = fopen(git_path("branches/%s", remote->name), "r");
- if (!f)
+ if (!f) {
+ if (errno != ENOENT)
+ warn_on_inaccessible(git_path("branches/%s",
+ remote->name));
return;
+ }
strbuf_getline_lf(&buf, f);
fclose(f);
--
2.11.0.157.gd943d85