2008-02-22 00:31:56 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2008 Charles Bailey
|
|
|
|
#
|
|
|
|
|
2008-09-03 10:59:33 +02:00
|
|
|
test_description='git mergetool
|
2008-02-22 00:31:56 +01:00
|
|
|
|
|
|
|
Testing basic merge tool invocation'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2009-01-31 00:20:10 +01:00
|
|
|
# All the mergetool test work by checking out a temporary branch based
|
|
|
|
# off 'branch1' and then merging in master and checking the results of
|
|
|
|
# running mergetool
|
|
|
|
|
2008-02-22 00:31:56 +01:00
|
|
|
test_expect_success 'setup' '
|
2014-10-15 10:35:20 +02:00
|
|
|
test_config rerere.enabled true &&
|
2014-10-15 10:35:17 +02:00
|
|
|
echo master >file1 &&
|
|
|
|
echo master spaced >"spaced name" &&
|
|
|
|
echo master file11 >file11 &&
|
|
|
|
echo master file12 >file12 &&
|
|
|
|
echo master file13 >file13 &&
|
|
|
|
echo master file14 >file14 &&
|
|
|
|
mkdir subdir &&
|
|
|
|
echo master sub >subdir/file3 &&
|
|
|
|
test_create_repo submod &&
|
|
|
|
(
|
|
|
|
cd submod &&
|
|
|
|
: >foo &&
|
|
|
|
git add foo &&
|
|
|
|
git commit -m "Add foo"
|
|
|
|
) &&
|
|
|
|
git submodule add git://example.com/submod submod &&
|
|
|
|
git add file1 "spaced name" file1[1-4] subdir/file3 .gitmodules submod &&
|
|
|
|
git commit -m "add initial versions" &&
|
|
|
|
|
|
|
|
git checkout -b branch1 master &&
|
|
|
|
git submodule update -N &&
|
|
|
|
echo branch1 change >file1 &&
|
|
|
|
echo branch1 newfile >file2 &&
|
|
|
|
echo branch1 spaced >"spaced name" &&
|
|
|
|
echo branch1 both added >both &&
|
|
|
|
echo branch1 change file11 >file11 &&
|
|
|
|
echo branch1 change file13 >file13 &&
|
|
|
|
echo branch1 sub >subdir/file3 &&
|
|
|
|
(
|
|
|
|
cd submod &&
|
|
|
|
echo branch1 submodule >bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m "Add bar on branch1" &&
|
|
|
|
git checkout -b submod-branch1
|
|
|
|
) &&
|
|
|
|
git add file1 "spaced name" file11 file13 file2 subdir/file3 submod &&
|
|
|
|
git add both &&
|
|
|
|
git rm file12 &&
|
|
|
|
git commit -m "branch1 changes" &&
|
|
|
|
|
2017-01-10 21:41:52 +01:00
|
|
|
git checkout -b delete-base branch1 &&
|
|
|
|
mkdir -p a/a &&
|
2018-07-02 02:23:42 +02:00
|
|
|
test_write_lines one two 3 4 >a/a/file.txt &&
|
2017-01-10 21:41:52 +01:00
|
|
|
git add a/a/file.txt &&
|
|
|
|
git commit -m"base file" &&
|
|
|
|
git checkout -b move-to-b delete-base &&
|
|
|
|
mkdir -p b/b &&
|
|
|
|
git mv a/a/file.txt b/b/file.txt &&
|
2018-07-02 02:23:42 +02:00
|
|
|
test_write_lines one two 4 >b/b/file.txt &&
|
2017-01-10 21:41:52 +01:00
|
|
|
git commit -a -m"move to b" &&
|
|
|
|
git checkout -b move-to-c delete-base &&
|
|
|
|
mkdir -p c/c &&
|
|
|
|
git mv a/a/file.txt c/c/file.txt &&
|
2018-07-02 02:23:42 +02:00
|
|
|
test_write_lines one two 3 >c/c/file.txt &&
|
2017-01-10 21:41:52 +01:00
|
|
|
git commit -a -m"move to c" &&
|
|
|
|
|
2014-10-15 10:35:17 +02:00
|
|
|
git checkout -b stash1 master &&
|
|
|
|
echo stash1 change file11 >file11 &&
|
|
|
|
git add file11 &&
|
|
|
|
git commit -m "stash1 changes" &&
|
|
|
|
|
|
|
|
git checkout -b stash2 master &&
|
|
|
|
echo stash2 change file11 >file11 &&
|
|
|
|
git add file11 &&
|
|
|
|
git commit -m "stash2 changes" &&
|
|
|
|
|
|
|
|
git checkout master &&
|
|
|
|
git submodule update -N &&
|
|
|
|
echo master updated >file1 &&
|
|
|
|
echo master new >file2 &&
|
|
|
|
echo master updated spaced >"spaced name" &&
|
|
|
|
echo master both added >both &&
|
|
|
|
echo master updated file12 >file12 &&
|
|
|
|
echo master updated file14 >file14 &&
|
|
|
|
echo master new sub >subdir/file3 &&
|
|
|
|
(
|
|
|
|
cd submod &&
|
|
|
|
echo master submodule >bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m "Add bar on master" &&
|
|
|
|
git checkout -b submod-master
|
|
|
|
) &&
|
|
|
|
git add file1 "spaced name" file12 file14 file2 subdir/file3 submod &&
|
|
|
|
git add both &&
|
|
|
|
git rm file11 &&
|
|
|
|
git commit -m "master updates" &&
|
|
|
|
|
2017-01-10 21:41:52 +01:00
|
|
|
git clean -fdx &&
|
|
|
|
git checkout -b order-file-start master &&
|
|
|
|
echo start >a &&
|
|
|
|
echo start >b &&
|
|
|
|
git add a b &&
|
|
|
|
git commit -m start &&
|
|
|
|
git checkout -b order-file-side1 order-file-start &&
|
|
|
|
echo side1 >a &&
|
|
|
|
echo side1 >b &&
|
|
|
|
git add a b &&
|
|
|
|
git commit -m side1 &&
|
|
|
|
git checkout -b order-file-side2 order-file-start &&
|
|
|
|
echo side2 >a &&
|
|
|
|
echo side2 >b &&
|
|
|
|
git add a b &&
|
|
|
|
git commit -m side2 &&
|
|
|
|
|
2014-10-15 10:35:17 +02:00
|
|
|
git config merge.tool mytool &&
|
|
|
|
git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
|
|
|
|
git config mergetool.mytool.trustExitCode true &&
|
|
|
|
git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" &&
|
|
|
|
git config mergetool.mybase.trustExitCode true
|
2009-01-31 00:20:10 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'custom mergetool' '
|
2017-01-10 21:41:55 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge master >/dev/null 2>&1 &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool file1 file1 ) &&
|
|
|
|
( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
|
|
|
|
test "$(cat file1)" = "master updated" &&
|
|
|
|
test "$(cat file2)" = "master new" &&
|
|
|
|
test "$(cat subdir/file3)" = "master new sub" &&
|
|
|
|
test "$(cat submod/bar)" = "branch1 submodule" &&
|
|
|
|
git commit -m "branch1 resolved with mergetool"
|
2009-01-21 23:57:48 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool crlf' '
|
2017-01-10 21:41:53 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
# This test_config line must go after the above reset line so that
|
|
|
|
# core.autocrlf is unconfigured before reset runs. (The
|
|
|
|
# test_config command uses test_when_finished internally and
|
|
|
|
# test_when_finished is LIFO.)
|
2014-10-15 10:35:20 +02:00
|
|
|
test_config core.autocrlf true &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test_must_fail git merge master >/dev/null 2>&1 &&
|
|
|
|
( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "r" | git mergetool submod >/dev/null 2>&1 ) &&
|
|
|
|
test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
|
|
|
|
test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
|
|
|
|
test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
2017-01-10 21:41:53 +01:00
|
|
|
git commit -m "branch1 resolved with mergetool - autocrlf"
|
2009-01-31 00:20:10 +01:00
|
|
|
'
|
|
|
|
|
2009-01-31 00:20:11 +01:00
|
|
|
test_expect_success 'mergetool in subdir' '
|
2017-01-10 21:41:55 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
test_must_fail git merge master >/dev/null 2>&1 &&
|
|
|
|
( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
|
|
|
|
test "$(cat file3)" = "master new sub"
|
|
|
|
)
|
2008-02-22 00:31:56 +01:00
|
|
|
'
|
|
|
|
|
2010-08-17 11:22:46 +02:00
|
|
|
test_expect_success 'mergetool on file in parent dir' '
|
2017-01-10 21:41:55 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:58 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2017-01-10 21:41:54 +01:00
|
|
|
git submodule update -N &&
|
2014-10-15 10:35:17 +02:00
|
|
|
(
|
|
|
|
cd subdir &&
|
2017-01-10 21:41:54 +01:00
|
|
|
test_must_fail git merge master >/dev/null 2>&1 &&
|
|
|
|
( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
|
2014-10-15 10:35:17 +02:00
|
|
|
( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool ../both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
|
|
|
|
test "$(cat ../file1)" = "master updated" &&
|
|
|
|
test "$(cat ../file2)" = "master new" &&
|
|
|
|
test "$(cat ../submod/bar)" = "branch1 submodule" &&
|
|
|
|
git commit -m "branch1 resolved with mergetool - subdir"
|
|
|
|
)
|
2010-08-17 11:22:46 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool skips autoresolved' '
|
2017-01-10 21:41:53 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
2017-01-10 21:41:53 +01:00
|
|
|
test "$output" = "No files need merging"
|
2010-08-17 11:22:46 +02:00
|
|
|
'
|
|
|
|
|
2017-01-10 21:42:00 +01:00
|
|
|
test_expect_success 'mergetool merges all from subdir (rerere disabled)' '
|
2017-01-10 21:41:55 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:58 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2015-09-05 15:12:45 +02:00
|
|
|
test_config rerere.enabled false &&
|
2014-10-15 10:35:17 +02:00
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
( yes "r" | git mergetool ../submod ) &&
|
|
|
|
( yes "d" "d" | git mergetool --no-prompt ) &&
|
|
|
|
test "$(cat ../file1)" = "master updated" &&
|
|
|
|
test "$(cat ../file2)" = "master new" &&
|
|
|
|
test "$(cat file3)" = "master new sub" &&
|
|
|
|
( cd .. && git submodule update -N ) &&
|
|
|
|
test "$(cat ../submod/bar)" = "master submodule" &&
|
|
|
|
git commit -m "branch2 resolved by mergetool from subdir"
|
|
|
|
)
|
2010-08-17 11:22:46 +02:00
|
|
|
'
|
2009-01-31 00:20:10 +01:00
|
|
|
|
2017-01-10 21:42:02 +01:00
|
|
|
test_expect_success 'mergetool merges all from subdir (rerere enabled)' '
|
2017-01-10 21:42:00 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git checkout -b test$test_count branch1 &&
|
|
|
|
test_config rerere.enabled true &&
|
|
|
|
rm -rf .git/rr-cache &&
|
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
test_must_fail git merge master &&
|
2014-10-15 10:35:17 +02:00
|
|
|
( yes "r" | git mergetool ../submod ) &&
|
|
|
|
( yes "d" "d" | git mergetool --no-prompt ) &&
|
|
|
|
test "$(cat ../file1)" = "master updated" &&
|
|
|
|
test "$(cat ../file2)" = "master new" &&
|
|
|
|
test "$(cat file3)" = "master new sub" &&
|
|
|
|
( cd .. && git submodule update -N ) &&
|
|
|
|
test "$(cat ../submod/bar)" = "master submodule" &&
|
|
|
|
git commit -m "branch2 resolved by mergetool from subdir"
|
|
|
|
)
|
2010-08-17 11:22:46 +02:00
|
|
|
'
|
2009-01-31 00:20:10 +01:00
|
|
|
|
2011-02-16 11:47:45 +01:00
|
|
|
test_expect_success 'mergetool skips resolved paths when rerere is active' '
|
2017-01-10 21:41:53 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2014-10-15 10:35:20 +02:00
|
|
|
test_config rerere.enabled true &&
|
2014-10-15 10:35:17 +02:00
|
|
|
rm -rf .git/rr-cache &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge master >/dev/null 2>&1 &&
|
|
|
|
( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) &&
|
|
|
|
git submodule update -N &&
|
|
|
|
output="$(yes "n" | git mergetool --no-prompt)" &&
|
2017-01-10 21:41:53 +01:00
|
|
|
test "$output" = "No files need merging"
|
2011-02-16 11:47:45 +01:00
|
|
|
'
|
|
|
|
|
2012-07-11 00:52:28 +02:00
|
|
|
test_expect_success 'conflicted stash sets up rerere' '
|
2017-01-10 21:41:55 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2014-10-15 10:35:20 +02:00
|
|
|
test_config rerere.enabled true &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git checkout stash1 &&
|
|
|
|
echo "Conflicting stash content" >file11 &&
|
|
|
|
git stash &&
|
|
|
|
|
|
|
|
git checkout --detach stash2 &&
|
|
|
|
test_must_fail git stash apply &&
|
|
|
|
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
conflicts="$(git rerere remaining)" &&
|
|
|
|
test "$conflicts" = "file11" &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" != "No files need merging" &&
|
|
|
|
|
|
|
|
git commit -am "save the stash resolution" &&
|
|
|
|
|
|
|
|
git reset --hard stash2 &&
|
|
|
|
test_must_fail git stash apply &&
|
|
|
|
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
conflicts="$(git rerere remaining)" &&
|
|
|
|
test -z "$conflicts" &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging"
|
2012-07-11 00:52:27 +02:00
|
|
|
'
|
|
|
|
|
2011-09-16 04:12:10 +02:00
|
|
|
test_expect_success 'mergetool takes partial path' '
|
2017-01-10 21:41:53 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2014-10-15 10:35:20 +02:00
|
|
|
test_config rerere.enabled false &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
|
|
|
|
( yes "" | git mergetool subdir ) &&
|
|
|
|
|
2017-01-10 21:41:53 +01:00
|
|
|
test "$(cat subdir/file3)" = "master new sub"
|
2011-09-16 04:12:10 +02:00
|
|
|
'
|
|
|
|
|
2016-03-10 08:13:58 +01:00
|
|
|
test_expect_success 'mergetool delete/delete conflict' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:57 +01:00
|
|
|
git checkout -b test$test_count move-to-c &&
|
2016-03-10 08:13:58 +01:00
|
|
|
test_must_fail git merge move-to-b &&
|
|
|
|
echo d | git mergetool a/a/file.txt &&
|
|
|
|
! test -f a/a/file.txt &&
|
2017-01-10 21:41:59 +01:00
|
|
|
git reset --hard &&
|
2016-03-10 08:13:58 +01:00
|
|
|
test_must_fail git merge move-to-b &&
|
|
|
|
echo m | git mergetool a/a/file.txt &&
|
|
|
|
test -f b/b/file.txt &&
|
2017-01-10 21:41:59 +01:00
|
|
|
git reset --hard &&
|
2016-03-10 08:13:58 +01:00
|
|
|
test_must_fail git merge move-to-b &&
|
|
|
|
! echo a | git mergetool a/a/file.txt &&
|
2017-01-10 21:41:53 +01:00
|
|
|
! test -f a/a/file.txt
|
2016-03-10 08:13:58 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool produces no errors when keepBackup is used' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:58 +01:00
|
|
|
git checkout -b test$test_count move-to-c &&
|
2016-03-10 08:13:58 +01:00
|
|
|
test_config mergetool.keepBackup true &&
|
|
|
|
test_must_fail git merge move-to-b &&
|
|
|
|
echo d | git mergetool a/a/file.txt 2>actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 23:57:25 +02:00
|
|
|
test_must_be_empty actual &&
|
2017-01-10 21:41:53 +01:00
|
|
|
! test -d a
|
2016-03-10 08:13:59 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool honors tempfile config for deleted files' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:58 +01:00
|
|
|
git checkout -b test$test_count move-to-c &&
|
2016-03-10 08:13:59 +01:00
|
|
|
test_config mergetool.keepTemporaries false &&
|
|
|
|
test_must_fail git merge move-to-b &&
|
|
|
|
echo d | git mergetool a/a/file.txt &&
|
2017-01-10 21:41:53 +01:00
|
|
|
! test -d a
|
2016-03-10 08:13:59 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:53 +01:00
|
|
|
test_when_finished "git clean -fdx" &&
|
2017-01-10 21:41:58 +01:00
|
|
|
git checkout -b test$test_count move-to-c &&
|
2016-03-10 08:13:59 +01:00
|
|
|
test_config mergetool.keepTemporaries true &&
|
|
|
|
test_must_fail git merge move-to-b &&
|
2018-07-02 02:23:42 +02:00
|
|
|
! test_write_lines a n | git mergetool a/a/file.txt &&
|
2016-03-10 08:13:59 +01:00
|
|
|
test -d a/a &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
file_BASE_.txt
|
|
|
|
file_LOCAL_.txt
|
|
|
|
file_REMOTE_.txt
|
|
|
|
EOF
|
|
|
|
ls -1 a/a | sed -e "s/[0-9]*//g" >actual &&
|
2017-01-10 21:41:53 +01:00
|
|
|
test_cmp expect actual
|
2016-03-10 08:13:58 +01:00
|
|
|
'
|
|
|
|
|
mergetool: Teach about submodules
When the index has conflicted submodules, mergetool used to mildly
clobber the module, renaming it to mymodule.BACKUP.nnnn, then failing to
copy it non-recursively.
Recognize submodules and offer a resolution instead:
Submodule merge conflict for 'Shared':
{local}: submodule commit ad9f12e3e6205381bf2163a793d1e596a9e211d0
{remote}: submodule commit f5893fb70ec5646efcd9aa643c5136753ac89253
Use (l)ocal or (r)emote, or (a)bort?
Selecting a commit will stage it, but not update the submodule (as git
does had there been no conflict). Type changes are also supported,
should the path be a submodule on one side, and a file, symlink,
directory, or deleted on the other.
Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 12:00:48 +02:00
|
|
|
test_expect_success 'deleted vs modified submodule' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
mv submod submod-movedaside &&
|
|
|
|
git rm --cached submod &&
|
|
|
|
git commit -m "Submodule deleted from branch" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.a test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "r" | git mergetool submod ) &&
|
|
|
|
rmdir submod && mv submod-movedaside submod &&
|
|
|
|
test "$(cat submod/bar)" = "branch1 submodule" &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by keeping module" &&
|
|
|
|
|
|
|
|
mv submod submod-movedaside &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.b test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "l" | git mergetool submod ) &&
|
|
|
|
test ! -e submod &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by deleting module" &&
|
|
|
|
|
|
|
|
mv submod-movedaside submod &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.c master &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "r" | git mergetool submod ) &&
|
|
|
|
test ! -e submod &&
|
|
|
|
test -d submod.orig &&
|
|
|
|
git submodule update -N &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by deleting module" &&
|
|
|
|
mv submod.orig submod &&
|
|
|
|
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.d master &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "l" | git mergetool submod ) &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
2017-01-10 21:41:53 +01:00
|
|
|
git commit -m "Merge resolved by keeping module"
|
mergetool: Teach about submodules
When the index has conflicted submodules, mergetool used to mildly
clobber the module, renaming it to mymodule.BACKUP.nnnn, then failing to
copy it non-recursively.
Recognize submodules and offer a resolution instead:
Submodule merge conflict for 'Shared':
{local}: submodule commit ad9f12e3e6205381bf2163a793d1e596a9e211d0
{remote}: submodule commit f5893fb70ec5646efcd9aa643c5136753ac89253
Use (l)ocal or (r)emote, or (a)bort?
Selecting a commit will stage it, but not update the submodule (as git
does had there been no conflict). Type changes are also supported,
should the path be a submodule on one side, and a file, symlink,
directory, or deleted on the other.
Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 12:00:48 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file vs modified submodule' '
|
2017-01-10 21:41:55 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
mv submod submod-movedaside &&
|
|
|
|
git rm --cached submod &&
|
|
|
|
echo not a submodule >submod &&
|
|
|
|
git add submod &&
|
|
|
|
git commit -m "Submodule path becomes file" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.a branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "r" | git mergetool submod ) &&
|
|
|
|
rmdir submod && mv submod-movedaside submod &&
|
|
|
|
test "$(cat submod/bar)" = "branch1 submodule" &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by keeping module" &&
|
|
|
|
|
|
|
|
mv submod submod-movedaside &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.b test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "l" | git mergetool submod ) &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod)" = "not a submodule" &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by keeping file" &&
|
|
|
|
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.c master &&
|
2014-10-15 10:35:17 +02:00
|
|
|
rmdir submod && mv submod-movedaside submod &&
|
|
|
|
test ! -e submod.orig &&
|
|
|
|
git submodule update -N &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "r" | git mergetool submod ) &&
|
|
|
|
test -d submod.orig &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod)" = "not a submodule" &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by keeping file" &&
|
|
|
|
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.d master &&
|
2014-10-15 10:35:17 +02:00
|
|
|
rmdir submod && mv submod.orig submod &&
|
|
|
|
git submodule update -N &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool both>/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "l" | git mergetool submod ) &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by keeping module"
|
mergetool: Teach about submodules
When the index has conflicted submodules, mergetool used to mildly
clobber the module, renaming it to mymodule.BACKUP.nnnn, then failing to
copy it non-recursively.
Recognize submodules and offer a resolution instead:
Submodule merge conflict for 'Shared':
{local}: submodule commit ad9f12e3e6205381bf2163a793d1e596a9e211d0
{remote}: submodule commit f5893fb70ec5646efcd9aa643c5136753ac89253
Use (l)ocal or (r)emote, or (a)bort?
Selecting a commit will stage it, but not update the submodule (as git
does had there been no conflict). Type changes are also supported,
should the path be a submodule on one side, and a file, symlink,
directory, or deleted on the other.
Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 12:00:48 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule in subdirectory' '
|
2017-01-10 21:41:55 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
test_create_repo subdir_module &&
|
|
|
|
(
|
|
|
|
cd subdir_module &&
|
|
|
|
: >file15 &&
|
|
|
|
git add file15 &&
|
|
|
|
git commit -m "add initial versions"
|
|
|
|
)
|
|
|
|
) &&
|
2017-01-10 21:41:53 +01:00
|
|
|
test_when_finished "rm -rf subdir/subdir_module" &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule add git://example.com/subsubmodule subdir/subdir_module &&
|
|
|
|
git add subdir/subdir_module &&
|
|
|
|
git commit -m "add submodule in subdirectory" &&
|
|
|
|
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.a test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
mergetool: Teach about submodules
When the index has conflicted submodules, mergetool used to mildly
clobber the module, renaming it to mymodule.BACKUP.nnnn, then failing to
copy it non-recursively.
Recognize submodules and offer a resolution instead:
Submodule merge conflict for 'Shared':
{local}: submodule commit ad9f12e3e6205381bf2163a793d1e596a9e211d0
{remote}: submodule commit f5893fb70ec5646efcd9aa643c5136753ac89253
Use (l)ocal or (r)emote, or (a)bort?
Selecting a commit will stage it, but not update the submodule (as git
does had there been no conflict). Type changes are also supported,
should the path be a submodule on one side, and a file, symlink,
directory, or deleted on the other.
Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 12:00:48 +02:00
|
|
|
(
|
|
|
|
cd subdir/subdir_module &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git checkout -b super10.a &&
|
2017-01-10 21:41:51 +01:00
|
|
|
echo test$test_count.a >file15 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git add file15 &&
|
|
|
|
git commit -m "on branch 10.a"
|
|
|
|
) &&
|
|
|
|
git add subdir/subdir_module &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git commit -m "change submodule in subdirectory on test$test_count.a" &&
|
2014-10-15 10:35:17 +02:00
|
|
|
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.b test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
|
|
|
(
|
|
|
|
cd subdir/subdir_module &&
|
|
|
|
git checkout -b super10.b &&
|
2017-01-10 21:41:51 +01:00
|
|
|
echo test$test_count.b >file15 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git add file15 &&
|
|
|
|
git commit -m "on branch 10.b"
|
|
|
|
) &&
|
|
|
|
git add subdir/subdir_module &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git commit -m "change submodule in subdirectory on test$test_count.b" &&
|
2014-10-15 10:35:17 +02:00
|
|
|
|
2017-01-10 21:41:51 +01:00
|
|
|
test_must_fail git merge test$test_count.a >/dev/null 2>&1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
( yes "l" | git mergetool subdir_module )
|
|
|
|
) &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git reset --hard &&
|
|
|
|
git submodule update -N &&
|
|
|
|
|
2017-01-10 21:41:51 +01:00
|
|
|
test_must_fail git merge test$test_count.a >/dev/null 2>&1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
( yes "r" | git mergetool subdir/subdir_module ) &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test "$(cat subdir/subdir_module/file15)" = "test$test_count.a" &&
|
2017-01-10 21:41:53 +01:00
|
|
|
git commit -m "branch1 resolved with mergetool"
|
mergetool: Teach about submodules
When the index has conflicted submodules, mergetool used to mildly
clobber the module, renaming it to mymodule.BACKUP.nnnn, then failing to
copy it non-recursively.
Recognize submodules and offer a resolution instead:
Submodule merge conflict for 'Shared':
{local}: submodule commit ad9f12e3e6205381bf2163a793d1e596a9e211d0
{remote}: submodule commit f5893fb70ec5646efcd9aa643c5136753ac89253
Use (l)ocal or (r)emote, or (a)bort?
Selecting a commit will stage it, but not update the submodule (as git
does had there been no conflict). Type changes are also supported,
should the path be a submodule on one side, and a file, symlink,
directory, or deleted on the other.
Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 12:00:48 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'directory vs modified submodule' '
|
2017-01-10 21:41:55 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
mv submod submod-movedaside &&
|
|
|
|
git rm --cached submod &&
|
|
|
|
mkdir submod &&
|
|
|
|
echo not a submodule >submod/file16 &&
|
|
|
|
git add submod/file16 &&
|
|
|
|
git commit -m "Submodule path becomes directory" &&
|
|
|
|
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "l" | git mergetool submod ) &&
|
|
|
|
test "$(cat submod/file16)" = "not a submodule" &&
|
|
|
|
rm -rf submod.orig &&
|
|
|
|
|
2017-01-10 21:41:59 +01:00
|
|
|
git reset --hard &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
test ! -e submod.orig &&
|
|
|
|
( yes "r" | git mergetool submod ) &&
|
|
|
|
test -d submod.orig &&
|
|
|
|
test "$(cat submod.orig/file16)" = "not a submodule" &&
|
|
|
|
rm -r submod.orig &&
|
|
|
|
mv submod-movedaside/.git submod &&
|
|
|
|
( cd submod && git clean -f && git reset --hard ) &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
2017-01-10 21:41:59 +01:00
|
|
|
git reset --hard &&
|
|
|
|
rm -rf submod-movedaside &&
|
2014-10-15 10:35:17 +02:00
|
|
|
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count.c master &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "l" | git mergetool submod ) &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
|
|
|
|
2017-01-10 21:41:59 +01:00
|
|
|
git reset --hard &&
|
2014-10-15 10:35:17 +02:00
|
|
|
git submodule update -N &&
|
2017-01-10 21:41:51 +01:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
test ! -e submod.orig &&
|
|
|
|
( yes "r" | git mergetool submod ) &&
|
|
|
|
test "$(cat submod/file16)" = "not a submodule" &&
|
|
|
|
|
2017-01-10 21:41:59 +01:00
|
|
|
git reset --hard master &&
|
2014-10-15 10:35:17 +02:00
|
|
|
( cd submod && git clean -f && git reset --hard ) &&
|
|
|
|
git submodule update -N
|
mergetool: Teach about submodules
When the index has conflicted submodules, mergetool used to mildly
clobber the module, renaming it to mymodule.BACKUP.nnnn, then failing to
copy it non-recursively.
Recognize submodules and offer a resolution instead:
Submodule merge conflict for 'Shared':
{local}: submodule commit ad9f12e3e6205381bf2163a793d1e596a9e211d0
{remote}: submodule commit f5893fb70ec5646efcd9aa643c5136753ac89253
Use (l)ocal or (r)emote, or (a)bort?
Selecting a commit will stage it, but not update the submodule (as git
does had there been no conflict). Type changes are also supported,
should the path be a submodule on one side, and a file, symlink,
directory, or deleted on the other.
Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 12:00:48 +02:00
|
|
|
'
|
|
|
|
|
2012-01-20 08:47:35 +01:00
|
|
|
test_expect_success 'file with no base' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test_must_fail git merge master &&
|
|
|
|
git mergetool --no-prompt --tool mybase -- both &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty both
|
2012-01-20 08:47:35 +01:00
|
|
|
'
|
|
|
|
|
2012-09-25 09:48:11 +02:00
|
|
|
test_expect_success 'custom commands override built-ins' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:20 +02:00
|
|
|
test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
|
|
|
|
test_config mergetool.defaults.trustExitCode true &&
|
2014-10-15 10:35:17 +02:00
|
|
|
test_must_fail git merge master &&
|
|
|
|
git mergetool --no-prompt --tool defaults -- both &&
|
|
|
|
echo master both added >expected &&
|
2017-10-06 21:00:06 +02:00
|
|
|
test_cmp expected both
|
2012-09-25 09:48:11 +02:00
|
|
|
'
|
|
|
|
|
2014-10-15 10:35:19 +02:00
|
|
|
test_expect_success 'filenames seen by tools start with ./' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:19 +02:00
|
|
|
test_config mergetool.writeToTemp false &&
|
|
|
|
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
|
|
|
|
test_config mergetool.myecho.trustExitCode true &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
git mergetool --no-prompt --tool myecho -- both >actual &&
|
2017-01-10 21:41:53 +01:00
|
|
|
grep ^\./both_LOCAL_ actual >/dev/null
|
2014-10-15 10:35:19 +02:00
|
|
|
'
|
|
|
|
|
2016-07-02 21:01:51 +02:00
|
|
|
test_lazy_prereq MKTEMP '
|
|
|
|
tempdir=$(mktemp -d -t foo.XXXXXX) &&
|
2016-11-27 07:34:45 +01:00
|
|
|
test -d "$tempdir" &&
|
|
|
|
rmdir "$tempdir"
|
2016-07-02 21:01:51 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:51 +01:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 10:35:19 +02:00
|
|
|
test_config mergetool.writeToTemp true &&
|
|
|
|
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
|
|
|
|
test_config mergetool.myecho.trustExitCode true &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
git mergetool --no-prompt --tool myecho -- both >actual &&
|
2017-01-03 20:57:07 +01:00
|
|
|
! grep ^\./both_LOCAL_ actual >/dev/null &&
|
2017-01-10 21:41:53 +01:00
|
|
|
grep /both_LOCAL_ actual >/dev/null
|
2014-10-15 10:35:19 +02:00
|
|
|
'
|
|
|
|
|
2016-10-08 01:58:05 +02:00
|
|
|
test_expect_success 'diff.orderFile configuration is honored' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:57 +01:00
|
|
|
git checkout -b test$test_count order-file-side2 &&
|
2016-10-08 01:58:05 +02:00
|
|
|
test_config diff.orderFile order-file &&
|
|
|
|
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
|
|
|
|
test_config mergetool.myecho.trustExitCode true &&
|
|
|
|
echo b >order-file &&
|
|
|
|
echo a >>order-file &&
|
|
|
|
test_must_fail git merge order-file-side1 &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
Merging:
|
|
|
|
b
|
|
|
|
a
|
|
|
|
EOF
|
2017-01-10 21:42:02 +01:00
|
|
|
|
|
|
|
# make sure "order-file" that is ambiguous between
|
|
|
|
# rev and path is understood correctly.
|
|
|
|
git branch order-file HEAD &&
|
|
|
|
|
2016-10-08 01:58:05 +02:00
|
|
|
git mergetool --no-prompt --tool myecho >output &&
|
|
|
|
git grep --no-index -h -A2 Merging: output >actual &&
|
2017-01-10 21:41:53 +01:00
|
|
|
test_cmp expect actual
|
2016-10-08 01:58:05 +02:00
|
|
|
'
|
2016-10-08 02:01:30 +02:00
|
|
|
test_expect_success 'mergetool -Oorder-file is honored' '
|
2017-01-10 21:41:59 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 21:41:58 +01:00
|
|
|
git checkout -b test$test_count order-file-side2 &&
|
2016-10-08 02:01:30 +02:00
|
|
|
test_config diff.orderFile order-file &&
|
|
|
|
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
|
|
|
|
test_config mergetool.myecho.trustExitCode true &&
|
2017-01-10 21:41:54 +01:00
|
|
|
echo b >order-file &&
|
|
|
|
echo a >>order-file &&
|
2016-10-08 02:01:30 +02:00
|
|
|
test_must_fail git merge order-file-side1 &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
Merging:
|
|
|
|
a
|
|
|
|
b
|
|
|
|
EOF
|
|
|
|
git mergetool -O/dev/null --no-prompt --tool myecho >output &&
|
|
|
|
git grep --no-index -h -A2 Merging: output >actual &&
|
|
|
|
test_cmp expect actual &&
|
2017-01-10 21:41:59 +01:00
|
|
|
git reset --hard &&
|
2016-10-08 02:01:30 +02:00
|
|
|
|
|
|
|
git config --unset diff.orderFile &&
|
|
|
|
test_must_fail git merge order-file-side1 &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
Merging:
|
|
|
|
b
|
|
|
|
a
|
|
|
|
EOF
|
|
|
|
git mergetool -Oorder-file --no-prompt --tool myecho >output &&
|
|
|
|
git grep --no-index -h -A2 Merging: output >actual &&
|
2017-01-10 21:41:53 +01:00
|
|
|
test_cmp expect actual
|
2016-10-08 02:01:30 +02:00
|
|
|
'
|
2016-10-08 01:58:05 +02:00
|
|
|
|
2008-02-22 00:31:56 +01:00
|
|
|
test_done
|