Skip to content

Commit a0db3e5

Browse files
committed
Merge branch 'jc/maint-1.6.1-checkout-m-custom-merge'
* jc/maint-1.6.1-checkout-m-custom-merge: checkout -m path: fix recreating conflicts Conflicts: t/t7201-co.sh
2 parents 42aac96 + 6d6f9ac commit a0db3e5

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

builtin-checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static int checkout_merged(int pos, struct checkout *state)
167167
fill_mm(active_cache[pos+2]->sha1, &theirs);
168168

169169
status = ll_merge(&result_buf, path, &ancestor,
170-
&ours, "ours", &theirs, "theirs", 1);
170+
&ours, "ours", &theirs, "theirs", 0);
171171
free(ancestor.ptr);
172172
free(ours.ptr);
173173
free(theirs.ptr);

t/t7201-co.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,4 +542,61 @@ test_expect_success 'switch out of non-branch' '
542542
! grep "^Previous HEAD" error.log
543543
'
544544

545+
(
546+
echo "#!$SHELL_PATH"
547+
cat <<\EOF
548+
O=$1 A=$2 B=$3
549+
cat "$A" >.tmp
550+
exec >"$A"
551+
echo '<<<<<<< filfre-theirs'
552+
cat "$B"
553+
echo '||||||| filfre-common'
554+
cat "$O"
555+
echo '======='
556+
cat ".tmp"
557+
echo '>>>>>>> filfre-ours'
558+
rm -f .tmp
559+
exit 1
560+
EOF
561+
) >filfre.sh
562+
chmod +x filfre.sh
563+
564+
test_expect_success 'custom merge driver with checkout -m' '
565+
git reset --hard &&
566+
567+
git config merge.filfre.driver "./filfre.sh %O %A %B" &&
568+
git config merge.filfre.name "Feel-free merge driver" &&
569+
git config merge.filfre.recursive binary &&
570+
echo "arm merge=filfre" >.gitattributes &&
571+
572+
git checkout -b left &&
573+
echo neutral >arm &&
574+
git add arm .gitattributes &&
575+
test_tick &&
576+
git commit -m neutral &&
577+
git branch right &&
578+
579+
echo left >arm &&
580+
test_tick &&
581+
git commit -a -m left &&
582+
git checkout right &&
583+
584+
echo right >arm &&
585+
test_tick &&
586+
git commit -a -m right &&
587+
588+
test_must_fail git merge left &&
589+
(
590+
for t in filfre-common left right
591+
do
592+
grep $t arm || exit 1
593+
done
594+
exit 0
595+
) &&
596+
597+
mv arm expect &&
598+
git checkout -m arm &&
599+
test_cmp expect arm
600+
'
601+
545602
test_done

0 commit comments

Comments
 (0)