From: Nguyễn Thái Ngọc Duy Date: Wed, 03 May 2017 10:16:54 GMT Subject: [PATCH v2 09/21] blame: report error on open if graft_file is a directory Message-ID: <20170503101706.9223-10-pclouds@gmail.com> In-Reply-To: <20170503101706.9223-1-pclouds@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/blame.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin/blame.c b/builtin/blame.c index 07506a3e45..1648b396dc 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -2071,10 +2071,12 @@ static int prepare_lines(struct scoreboard *sb) */ static int read_ancestry(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