Skip to content

Commit

Permalink
reduce_heads(): thinkofix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sverre Hvammen Johansen authored and Junio C Hamano committed Jul 13, 2008
1 parent 3f4d1c6 commit 3d1dd47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)

num_other = 0;
for (q = heads; q; q = q->next) {
if (p == q)
if (p->item == q->item)
continue;
other[num_other++] = q->item;
}
Expand Down
11 changes: 11 additions & 0 deletions t/t7600-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,15 @@ test_expect_success 'merge log message' '

test_debug 'gitk --all'

test_expect_success 'merge c1 with c0, c2, c0, and c1' '
git reset --hard c1 &&
git config branch.master.mergeoptions "" &&
test_tick &&
git merge c0 c2 c0 c1 &&
verify_merge file result.1-5 &&
verify_parents $c1 $c2
'

test_debug 'gitk --all'

test_done

0 comments on commit 3d1dd47

Please sign in to comment.