Skip to content

Commit

Permalink
merge: use return value of resolve_ref() to determine if HEAD is invalid
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Sep 18, 2011
1 parent b4fd940 commit 10b98fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
branch = resolve_ref("HEAD", head, 0, &flag);
if (branch && !prefixcmp(branch, "refs/heads/"))
branch += 11;
if (is_null_sha1(head))
if (!branch || is_null_sha1(head))
head_invalid = 1;

git_config(git_merge_config, NULL);
Expand Down

0 comments on commit 10b98fa

Please sign in to comment.