Skip to content

Commit 10b98fa

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b4fd940 commit 10b98fa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
10301030
branch = resolve_ref("HEAD", head, 0, &flag);
10311031
if (branch && !prefixcmp(branch, "refs/heads/"))
10321032
branch += 11;
1033-
if (is_null_sha1(head))
1033+
if (!branch || is_null_sha1(head))
10341034
head_invalid = 1;
10351035

10361036
git_config(git_merge_config, NULL);

0 commit comments

Comments
 (0)