@matheusbsbs / matheus-bagliano / commits / 6d6f9acc5d
Fork 0

checkout -m path: fix recreating conflicts

We should tell ll_merge() that the 3-way merge between stages #2 and #3 is an outermost merge, not a virtual-ancestor creation. Back when this code was originally written, users couldn't write custom merge drivers easily, so the bug didn't matter, but these days it does. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 6, 2010 at 12:32 UTC 6d6f9acc5db0dfae94ef22c9ecbcf7df00f84399
2 files changed +58 -1
builtin-checkout.c
+1 -1
@@ -179,7 +179,7 @@ static int checkout_merged(int pos, struct checkout *state)
179 fill_mm(active_cache[pos+2]->sha1, &theirs);
180
181 status = ll_merge(&result_buf, path, &ancestor,
182 - &ours, "ours", &theirs, "theirs", 1);
182 + &ours, "ours", &theirs, "theirs", 0);
183 free(ancestor.ptr);
184 free(ours.ptr);
185 free(theirs.ptr);
t/t7201-co.sh
+57
@@ -534,4 +534,61 @@ test_expect_success 'failing checkout -b should not break working tree' '
534
535 '
536
537 +(
538 + echo "#!$SHELL_PATH"
539 + cat <<\EOF
540 +O=$1 A=$2 B=$3
541 +cat "$A" >.tmp
542 +exec >"$A"
543 +echo '<<<<<<< filfre-theirs'
544 +cat "$B"
545 +echo '||||||| filfre-common'
546 +cat "$O"
547 +echo '======='
548 +cat ".tmp"
549 +echo '>>>>>>> filfre-ours'
550 +rm -f .tmp
551 +exit 1
552 +EOF
553 +) >filfre.sh
554 +chmod +x filfre.sh
555 +
556 +test_expect_success 'custom merge driver with checkout -m' '
557 + git reset --hard &&
558 +
559 + git config merge.filfre.driver "./filfre.sh %O %A %B" &&
560 + git config merge.filfre.name "Feel-free merge driver" &&
561 + git config merge.filfre.recursive binary &&
562 + echo "arm merge=filfre" >.gitattributes &&
563 +
564 + git checkout -b left &&
565 + echo neutral >arm &&
566 + git add arm .gitattributes &&
567 + test_tick &&
568 + git commit -m neutral &&
569 + git branch right &&
570 +
571 + echo left >arm &&
572 + test_tick &&
573 + git commit -a -m left &&
574 + git checkout right &&
575 +
576 + echo right >arm &&
577 + test_tick &&
578 + git commit -a -m right &&
579 +
580 + test_must_fail git merge left &&
581 + (
582 + for t in filfre-common left right
583 + do
584 + grep $t arm || exit 1
585 + done
586 + exit 0
587 + ) &&
588 +
589 + mv arm expect &&
590 + git checkout -m arm &&
591 + test_cmp expect arm
592 +'
593 +
594 test_done