Skip to content

Commit f476143

Browse files
miallogitster
authored andcommitted
revision: ensure MERGE_HEAD is a ref in prepare_show_merge
This is done to (1) ensure MERGE_HEAD is a ref, (2) obtain the oid without any prefixing by refs.c:repo_dwim_ref() (3) error out when MERGE_HEAD is a symref. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Michael Lohmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Philippe Blain <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 186b115 commit f476143

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

revision.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1973,8 +1973,12 @@ static void prepare_show_merge(struct rev_info *revs)
19731973
if (repo_get_oid(the_repository, "HEAD", &oid))
19741974
die("--merge without HEAD?");
19751975
head = lookup_commit_or_die(&oid, "HEAD");
1976-
if (repo_get_oid(the_repository, "MERGE_HEAD", &oid))
1976+
if (read_ref_full("MERGE_HEAD",
1977+
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
1978+
&oid, NULL))
19771979
die("--merge without MERGE_HEAD?");
1980+
if (is_null_oid(&oid))
1981+
die(_("MERGE_HEAD exists but is a symbolic ref"));
19781982
other = lookup_commit_or_die(&oid, "MERGE_HEAD");
19791983
add_pending_object(revs, &head->object, "HEAD");
19801984
add_pending_object(revs, &other->object, "MERGE_HEAD");

0 commit comments

Comments
 (0)