merge: use return value of resolve_ref() to determine if HEAD is invalid

resolve_ref() only updates "head" when it returns non NULL value (it may update "head" even when returning NULL, but not in all cases). Because "head" is not initialized before the call, is_null_sha1() is not enough. Check also resolve_ref() return value. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Sep 17, 2011 at 21:57 UTC 10b98fa5b3fab4a4ba46f31b58f8da703b465b68
1 file changed +1 -1
builtin/merge.c
+1 -1
@@ -1030,7 +1030,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1030 branch = resolve_ref("HEAD", head, 0, &flag);
1031 if (branch && !prefixcmp(branch, "refs/heads/"))
1032 branch += 11;
1033 - if (is_null_sha1(head))
1033 + if (!branch || is_null_sha1(head))
1034 head_invalid = 1;
1035
1036 git_config(git_merge_config, NULL);