aboutsummaryrefslogtreecommitdiffstats
path: root/remote.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2017-05-03 17:16:50 +0700
committerJunio C Hamano <gitster@pobox.com>2017-05-26 12:33:56 +0900
commite9d983f116c7de43f40a49aae60ebfe107f153ec (patch)
tree2d1b2b10e651eb3dd941a10379719c9abd8ef993 /remote.c
parent11dc1fcb3fa53f5a46486daa7cb38ed387153f2e (diff)
downloadgit-e9d983f116c7de43f40a49aae60ebfe107f153ec.tar.gz
wrapper.c: add and use fopen_or_warn()
When fopen() returns NULL, it could be because the given path does not exist, but it could also be some other errors and the caller has to check. Add a wrapper so we don't have to repeat the same error check everywhere. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/remote.c b/remote.c
index 801137c72e..1f2453d0f6 100644
--- a/remote.c
+++ b/remote.c
@@ -251,7 +251,7 @@ static const char *skip_spaces(const char *s)
static void read_remotes_file(struct remote *remote)
{
struct strbuf buf = STRBUF_INIT;
- FILE *f = fopen(git_path("remotes/%s", remote->name), "r");
+ FILE *f = fopen_or_warn(git_path("remotes/%s", remote->name), "r");
if (!f)
return;
@@ -277,7 +277,7 @@ static void read_branches_file(struct remote *remote)
{
char *frag;
struct strbuf buf = STRBUF_INIT;
- FILE *f = fopen(git_path("branches/%s", remote->name), "r");
+ FILE *f = fopen_or_warn(git_path("branches/%s", remote->name), "r");
if (!f)
return;