Skip to content

Commit 57f75f3

Browse files
committed
Merge branch 'cn/maint-branch-with-bad' into maint
* cn/maint-branch-with-bad: branch: don't assume the merge filter ref exists Conflicts: t/t3200-branch.sh
2 parents 3ecd0c8 + 6c41e97 commit 57f75f3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

builtin/branch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
530530
if (merge_filter != NO_FILTER) {
531531
struct commit *filter;
532532
filter = lookup_commit_reference_gently(merge_filter_ref, 0);
533+
if (!filter)
534+
die("object '%s' does not point to a commit",
535+
sha1_to_hex(merge_filter_ref));
536+
533537
filter->object.flags |= UNINTERESTING;
534538
add_pending_object(&ref_list.revs,
535539
(struct object *) filter, "");

t/t3200-branch.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,4 +653,8 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '
653653
)
654654
'
655655

656+
test_expect_success '--merged catches invalid object names' '
657+
test_must_fail git branch --merged 0000000000000000000000000000000000000000
658+
'
659+
656660
test_done

0 commit comments

Comments
 (0)