diff options
author | Michael Lohmann <mi.al.lohmann@gmail.com> | 2024-02-28 14:54:53 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-28 19:02:46 +0100 |
commit | f476143ee6c8a58f41c569e4a637bc441b1e6f4a (patch) | |
tree | c20bac1753d024fbddfdd7423e989d6b0279ea6e /revision.c | |
parent | The eighth batch (diff) | |
download | git-f476143ee6c8a58f41c569e4a637bc441b1e6f4a.tar.xz git-f476143ee6c8a58f41c569e4a637bc441b1e6f4a.zip |
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 <gitster@pobox.com>
Signed-off-by: Michael Lohmann <mi.al.lohmann@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/revision.c b/revision.c index 2424c9bd67..df775f74d0 100644 --- a/revision.c +++ b/revision.c @@ -1973,8 +1973,12 @@ static void prepare_show_merge(struct rev_info *revs) if (repo_get_oid(the_repository, "HEAD", &oid)) die("--merge without HEAD?"); head = lookup_commit_or_die(&oid, "HEAD"); - if (repo_get_oid(the_repository, "MERGE_HEAD", &oid)) + if (read_ref_full("MERGE_HEAD", + RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE, + &oid, NULL)) die("--merge without MERGE_HEAD?"); + if (is_null_oid(&oid)) + die(_("MERGE_HEAD exists but is a symbolic ref")); other = lookup_commit_or_die(&oid, "MERGE_HEAD"); add_pending_object(revs, &head->object, "HEAD"); add_pending_object(revs, &other->object, "MERGE_HEAD"); |