From: Nguyễn Thái Ngọc Duy Date: Wed, 03 May 2017 10:16:57 GMT Subject: [PATCH v2 12/21] commit.c: report error on failure to fopen() the graft file Message-ID: <20170503101706.9223-13-pclouds@gmail.com> In-Reply-To: <20170503101706.9223-1-pclouds@gmail.com> Suppressing the error (because the command requires --quiet) is not a concern because we already call error() just a couple lines down. Signed-off-by: Nguyễn Thái Ngọc Duy --- commit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commit.c b/commit.c index 73c78c2b80..075607a6da 100644 --- a/commit.c +++ b/commit.c @@ -167,10 +167,12 @@ struct commit_graft *read_graft_line(char *buf, int len) static int read_graft_file(const char *graft_file) { - FILE *fp = fopen(graft_file, "r"); + FILE *fp = fopen_or_warn(graft_file, "r"); struct strbuf buf = STRBUF_INIT; + if (!fp) return -1; + while (!strbuf_getwholeline(&buf, fp, '\n')) { /* The format is just "Commit Parent1 Parent2 ...\n" */ struct commit_graft *graft = read_graft_line(buf.buf, buf.len); -- 2.11.0.157.gd943d85