@matheusbsbs / matheus-bagliano / commits / 3d1dd4728b
Fork 0

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>

Sverre Hvammen Johansen committed Jul 13, 2008 at 08:13 UTC 3d1dd4728b83e4c08d9fa7aaf2aa946e1012e061
2 files changed +12 -1
commit.c
+1 -1
@@ -747,7 +747,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)
747
748 num_other = 0;
749 for (q = heads; q; q = q->next) {
750 - if (p == q)
750 + if (p->item == q->item)
751 continue;
752 other[num_other++] = q->item;
753 }
t/t7600-merge.sh
+11
@@ -479,4 +479,15 @@ test_expect_success 'merge log message' '
479
480 test_debug 'gitk --all'
481
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 +
493 test_done