merge-recursive: copy $GITHEAD strings
commitd64bb065c0279e523db5270bbcf0ddda74fa9c8f
authorJeff King <peff@peff.net>
Fri, 11 Jan 2019 22:16:55 +0000 (11 17:16 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sat, 12 Jan 2019 02:48:59 +0000 (11 18:48 -0800)
treeb67050d2ee715cd630bd1e67dd6e54af06f38779
parente5b07c539deefb13a4830fe9303e3d7590713f26
merge-recursive: copy $GITHEAD strings

If $GITHEAD_1234abcd is set in the environment, we use its value as a
"better branch name" in generating conflict markers. However, we pick
these better names early in the process, and the return value from
getenv() is not guaranteed to stay valid.

Let's make a copy of the returned string. And to make memory management
easier, let's just always return an allocated string from
better_branch_name(), so we know that it must always be freed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge-recursive.c