From 10b98fa5b3fab4a4ba46f31b58f8da703b465b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 17 Sep 2011 21:57:43 +1000 Subject: merge: use return value of resolve_ref() to determine if HEAD is invalid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- builtin/merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/merge.c b/builtin/merge.c index a068660d0..c371484ab 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -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); -- cgit v1.2.1