[PATCH 07/15] remote.c: report error on failure to fopen()
- From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Date
- Apr 20, 2017, 11:26 UTC
- Message-ID
- <20170420112609.26089-8-pclouds@gmail.com>
- In-Reply-To
- <20170420112609.26089-1-pclouds@gmail.com>
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@gmail.com> --- 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