Skip to content

Commit 3d1dd47

Browse files
hvammengitster
authored andcommitted
reduce_heads(): thinkofix
When comparing two commit objects for equality, it is sufficient to compare their in-core pointers because the object layer guarantees the uniqueness. However, comparing pointers to two "struct commit_list" instances that point at the same commit does not make any sense. Spotted by Sverre Hvammen Johansen who wrote an additional test to expose the problem, fixed by Miklos Vajna. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3f4d1c6 commit 3d1dd47

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)
747747

748748
num_other = 0;
749749
for (q = heads; q; q = q->next) {
750-
if (p == q)
750+
if (p->item == q->item)
751751
continue;
752752
other[num_other++] = q->item;
753753
}

t/t7600-merge.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,15 @@ test_expect_success 'merge log message' '
479479

480480
test_debug 'gitk --all'
481481

482+
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
483+
git reset --hard c1 &&
484+
git config branch.master.mergeoptions "" &&
485+
test_tick &&
486+
git merge c0 c2 c0 c1 &&
487+
verify_merge file result.1-5 &&
488+
verify_parents $c1 $c2
489+
'
490+
491+
test_debug 'gitk --all'
492+
482493
test_done

0 commit comments

Comments
 (0)