checkout: provide better conflict hunk description with detached HEAD
commit65c01c644250fb0a92f929c2fc61f33771bf480f
authorElijah Newren <newren@gmail.com>
Thu, 15 Aug 2019 21:40:31 +0000 (15 14:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Aug 2019 19:47:20 +0000 (16 12:47 -0700)
treef0cd0dbe3cf0b39f52a836390a36f1d8aff294c6
parentd8523ca1b90641be4bddcdfc50fbf3a1be34adae
checkout: provide better conflict hunk description with detached HEAD

When running 'git checkout -m' and using diff3 style conflict markers,
we want all the conflict hunks (left-side, "common" or "merge base", and
right-side) to have label markers letting the user know where each came
from.  The "common" hunk label (o.ancestor) came from
old_branch_info->name, but that is NULL when HEAD is detached, which
resulted in a blank label.  Check for that case and provide an
abbreviated commit hash instead.

(Incidentally, this was the only case in the git codebase where
merge_trees() was called with opt->ancestor being NULL.  A subsequent
commit will prevent similar problems by enforcing that merge_trees()
always be called with opt->ancestor != NULL.)

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c