Add check of the resolved HEAD reference while printing of a commit summary. resolve_ref_unsafe() may return NULL pointer if underlying calls of lstat() or open() fail in files_read_raw_ref(). Such situation can be caused by race: file becomes inaccessible to this moment. Signed-off-by: Andrey Okoshkin <a.okoshkin@xxxxxxxxxxx> --- Hello, I think this way is better for user experience: * git doesn't crash; * warning is shown; * commit has been successfully created then it's safe to show a summary message with already known information and without resolved HEAD. Best regards, Andrey builtin/commit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builtin/commit.c b/builtin/commit.c index 1a0da71a4..647d6ab3e 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1483,7 +1483,10 @@ static void print_summary(const char *prefix, const struct object_id *oid, diff_setup_done(&rev.diffopt); head = resolve_ref_unsafe("HEAD", 0, junk_oid.hash, NULL); - if (!strcmp(head, "HEAD")) + if (!head) { + warning_errno(_("unable to resolve HEAD after creating commit")); + head = _("unresolvable HEAD"); + } else if (!strcmp(head, "HEAD")) head = _("detached HEAD"); else skip_prefix(head, "refs/heads/", &head); -- 2.14.2