2008-02-21 23:31:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2008 Charles Bailey
|
|
|
|
#
|
|
|
|
|
2008-09-03 08:59:33 +00:00
|
|
|
test_description='git mergetool
|
2008-02-21 23:31:56 +00:00
|
|
|
|
|
|
|
Testing basic merge tool invocation'
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-18 23:44:19 +00:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
2008-02-21 23:31:56 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
2009-01-30 23:20:10 +00:00
|
|
|
# All the mergetool test work by checking out a temporary branch based
|
2020-11-18 23:44:40 +00:00
|
|
|
# off 'branch1' and then merging in main and checking the results of
|
2009-01-30 23:20:10 +00:00
|
|
|
# running mergetool
|
|
|
|
|
2008-02-21 23:31:56 +00:00
|
|
|
test_expect_success 'setup' '
|
2014-10-15 08:35:20 +00:00
|
|
|
test_config rerere.enabled true &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo main >file1 &&
|
|
|
|
echo main spaced >"spaced name" &&
|
|
|
|
echo main file11 >file11 &&
|
|
|
|
echo main file12 >file12 &&
|
|
|
|
echo main file13 >file13 &&
|
|
|
|
echo main file14 >file14 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
mkdir subdir &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo main sub >subdir/file3 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
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" &&
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b branch1 main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
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 20:41:52 +00:00
|
|
|
git checkout -b delete-base branch1 &&
|
|
|
|
mkdir -p a/a &&
|
2018-07-02 00:23:42 +00:00
|
|
|
test_write_lines one two 3 4 >a/a/file.txt &&
|
2017-01-10 20:41:52 +00: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 00:23:42 +00:00
|
|
|
test_write_lines one two 4 >b/b/file.txt &&
|
2017-01-10 20:41:52 +00: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 00:23:42 +00:00
|
|
|
test_write_lines one two 3 >c/c/file.txt &&
|
2017-01-10 20:41:52 +00:00
|
|
|
git commit -a -m"move to c" &&
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b stash1 main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
echo stash1 change file11 >file11 &&
|
|
|
|
git add file11 &&
|
|
|
|
git commit -m "stash1 changes" &&
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b stash2 main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
echo stash2 change file11 >file11 &&
|
|
|
|
git add file11 &&
|
|
|
|
git commit -m "stash2 changes" &&
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo main updated >file1 &&
|
|
|
|
echo main new >file2 &&
|
|
|
|
echo main updated spaced >"spaced name" &&
|
|
|
|
echo main both added >both &&
|
|
|
|
echo main updated file12 >file12 &&
|
|
|
|
echo main updated file14 >file14 &&
|
|
|
|
echo main new sub >subdir/file3 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
(
|
|
|
|
cd submod &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo main submodule >bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git add bar &&
|
2020-11-18 23:44:40 +00:00
|
|
|
git commit -m "Add bar on main" &&
|
|
|
|
git checkout -b submod-main
|
2014-10-15 08:35:17 +00:00
|
|
|
) &&
|
|
|
|
git add file1 "spaced name" file12 file14 file2 subdir/file3 submod &&
|
|
|
|
git add both &&
|
|
|
|
git rm file11 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
git commit -m "main updates" &&
|
2014-10-15 08:35:17 +00:00
|
|
|
|
2017-01-10 20:41:52 +00:00
|
|
|
git clean -fdx &&
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b order-file-start main &&
|
2017-01-10 20:41:52 +00:00
|
|
|
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 08:35:17 +00: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-30 23:20:10 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'custom mergetool' '
|
2017-01-10 20:41:55 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "" | git mergetool file1 file1 &&
|
|
|
|
yes "" | git mergetool file2 "spaced name" &&
|
|
|
|
yes "" | git mergetool subdir/file3 &&
|
|
|
|
yes "d" | git mergetool file11 &&
|
|
|
|
yes "d" | git mergetool file12 &&
|
|
|
|
yes "l" | git mergetool submod &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main updated" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file2 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new sub" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect subdir/file3 &&
|
|
|
|
echo "branch1 submodule" >expect &&
|
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git commit -m "branch1 resolved with mergetool"
|
2019-04-24 22:46:59 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'gui mergetool' '
|
|
|
|
test_config merge.guitool myguitool &&
|
|
|
|
test_config mergetool.myguitool.cmd "(printf \"gui \" && cat \"\$REMOTE\") >\"\$MERGED\"" &&
|
|
|
|
test_config mergetool.myguitool.trustExitCode true &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git checkout -b test$test_count branch1 &&
|
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool --gui both &&
|
|
|
|
yes "" | git mergetool -g file1 file1 &&
|
|
|
|
yes "" | git mergetool --gui file2 "spaced name" &&
|
|
|
|
yes "" | git mergetool --gui subdir/file3 &&
|
|
|
|
yes "d" | git mergetool --gui file11 &&
|
|
|
|
yes "d" | git mergetool --gui file12 &&
|
|
|
|
yes "l" | git mergetool --gui submod &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "gui main updated" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "gui main new" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file2 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "gui main new sub" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect subdir/file3 &&
|
|
|
|
echo "branch1 submodule" >expect &&
|
|
|
|
test_cmp expect submod/bar &&
|
2019-04-24 22:46:59 +00:00
|
|
|
git commit -m "branch1 resolved with mergetool"
|
2019-04-29 06:21:14 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'gui mergetool without merge.guitool set falls back to merge.tool' '
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git checkout -b test$test_count branch1 &&
|
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool --gui both &&
|
|
|
|
yes "" | git mergetool -g file1 file1 &&
|
|
|
|
yes "" | git mergetool --gui file2 "spaced name" &&
|
|
|
|
yes "" | git mergetool --gui subdir/file3 &&
|
|
|
|
yes "d" | git mergetool --gui file11 &&
|
|
|
|
yes "d" | git mergetool --gui file12 &&
|
|
|
|
yes "l" | git mergetool --gui submod &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main updated" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file2 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new sub" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect subdir/file3 &&
|
|
|
|
echo "branch1 submodule" >expect &&
|
|
|
|
test_cmp expect submod/bar &&
|
2019-04-29 06:21:14 +00:00
|
|
|
git commit -m "branch1 resolved with mergetool"
|
2009-01-21 22:57:48 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool crlf' '
|
2017-01-10 20:41:53 +00: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 08:35:20 +00:00
|
|
|
test_config core.autocrlf true &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 &&
|
|
|
|
yes "" | git mergetool file2 &&
|
|
|
|
yes "" | git mergetool "spaced name" &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "" | git mergetool subdir/file3 &&
|
|
|
|
yes "d" | git mergetool file11 &&
|
|
|
|
yes "d" | git mergetool file12 &&
|
|
|
|
yes "r" | git mergetool submod &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test "$(printf x | cat file1 -)" = "$(printf "main updated\r\nx")" &&
|
|
|
|
test "$(printf x | cat file2 -)" = "$(printf "main new\r\nx")" &&
|
|
|
|
test "$(printf x | cat subdir/file3 -)" = "$(printf "main new sub\r\nx")" &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2017-01-10 20:41:53 +00:00
|
|
|
git commit -m "branch1 resolved with mergetool - autocrlf"
|
2009-01-30 23:20:10 +00:00
|
|
|
'
|
|
|
|
|
2009-01-30 23:20:11 +00:00
|
|
|
test_expect_success 'mergetool in subdir' '
|
2017-01-10 20:41:55 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
|
|
|
(
|
|
|
|
cd subdir &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file3 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new sub" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file3
|
2014-10-15 08:35:17 +00:00
|
|
|
)
|
2008-02-21 23:31:56 +00:00
|
|
|
'
|
|
|
|
|
2010-08-17 09:22:46 +00:00
|
|
|
test_expect_success 'mergetool on file in parent dir' '
|
2017-01-10 20:41:55 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:58 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2017-01-10 20:41:54 +00:00
|
|
|
git submodule update -N &&
|
2014-10-15 08:35:17 +00:00
|
|
|
(
|
|
|
|
cd subdir &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file3 &&
|
|
|
|
yes "" | git mergetool ../file1 &&
|
|
|
|
yes "" | git mergetool ../file2 ../spaced\ name &&
|
|
|
|
yes "" | git mergetool ../both &&
|
|
|
|
yes "d" | git mergetool ../file11 &&
|
|
|
|
yes "d" | git mergetool ../file12 &&
|
|
|
|
yes "l" | git mergetool ../submod &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main updated" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect ../file1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect ../file2 &&
|
|
|
|
echo "branch1 submodule" >expect &&
|
|
|
|
test_cmp expect ../submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git commit -m "branch1 resolved with mergetool - subdir"
|
|
|
|
)
|
2010-08-17 09:22:46 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool skips autoresolved' '
|
2017-01-10 20:41:53 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "d" | git mergetool file11 &&
|
|
|
|
yes "d" | git mergetool file12 &&
|
|
|
|
yes "l" | git mergetool submod &&
|
2014-10-15 08:35:17 +00:00
|
|
|
output="$(git mergetool --no-prompt)" &&
|
2017-01-10 20:41:53 +00:00
|
|
|
test "$output" = "No files need merging"
|
2010-08-17 09:22:46 +00:00
|
|
|
'
|
|
|
|
|
2017-01-10 20:42:00 +00:00
|
|
|
test_expect_success 'mergetool merges all from subdir (rerere disabled)' '
|
2017-01-10 20:41:55 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:58 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2015-09-05 13:12:45 +00:00
|
|
|
test_config rerere.enabled false &&
|
2014-10-15 08:35:17 +00:00
|
|
|
(
|
|
|
|
cd subdir &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "r" | git mergetool ../submod &&
|
|
|
|
yes "d" "d" | git mergetool --no-prompt &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main updated" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect ../file1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect ../file2 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new sub" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file3 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
( cd .. && git submodule update -N ) &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect ../submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git commit -m "branch2 resolved by mergetool from subdir"
|
|
|
|
)
|
2010-08-17 09:22:46 +00:00
|
|
|
'
|
2009-01-30 23:20:10 +00:00
|
|
|
|
2017-01-10 20:42:02 +00:00
|
|
|
test_expect_success 'mergetool merges all from subdir (rerere enabled)' '
|
2017-01-10 20:42:00 +00: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 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "r" | git mergetool ../submod &&
|
|
|
|
yes "d" "d" | git mergetool --no-prompt &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main updated" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect ../file1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect ../file2 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new sub" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect file3 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
( cd .. && git submodule update -N ) &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect ../submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git commit -m "branch2 resolved by mergetool from subdir"
|
|
|
|
)
|
2010-08-17 09:22:46 +00:00
|
|
|
'
|
2009-01-30 23:20:10 +00:00
|
|
|
|
2011-02-16 10:47:45 +00:00
|
|
|
test_expect_success 'mergetool skips resolved paths when rerere is active' '
|
2017-01-10 20:41:53 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2014-10-15 08:35:20 +00:00
|
|
|
test_config rerere.enabled true &&
|
2014-10-15 08:35:17 +00:00
|
|
|
rm -rf .git/rr-cache &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "l" | git mergetool --no-prompt submod &&
|
|
|
|
yes "d" "d" | git mergetool --no-prompt &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
|
|
|
output="$(yes "n" | git mergetool --no-prompt)" &&
|
2017-01-10 20:41:53 +00:00
|
|
|
test "$output" = "No files need merging"
|
2011-02-16 10:47:45 +00:00
|
|
|
'
|
|
|
|
|
2012-07-10 22:52:28 +00:00
|
|
|
test_expect_success 'conflicted stash sets up rerere' '
|
2017-01-10 20:41:55 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2014-10-15 08:35:20 +00:00
|
|
|
test_config rerere.enabled true &&
|
2014-10-15 08:35:17 +00: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-10 22:52:27 +00:00
|
|
|
'
|
|
|
|
|
2011-09-16 02:12:10 +00:00
|
|
|
test_expect_success 'mergetool takes partial path' '
|
2017-01-10 20:41:53 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2014-10-15 08:35:20 +00:00
|
|
|
test_config rerere.enabled false &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool subdir &&
|
2014-10-15 08:35:17 +00:00
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main new sub" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect subdir/file3
|
2011-09-16 02:12:10 +00:00
|
|
|
'
|
|
|
|
|
2016-03-10 07:13:58 +00:00
|
|
|
test_expect_success 'mergetool delete/delete conflict' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:57 +00:00
|
|
|
git checkout -b test$test_count move-to-c &&
|
2016-03-10 07:13:58 +00: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 20:41:59 +00:00
|
|
|
git reset --hard &&
|
2016-03-10 07:13:58 +00: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 20:41:59 +00:00
|
|
|
git reset --hard &&
|
2016-03-10 07:13:58 +00:00
|
|
|
test_must_fail git merge move-to-b &&
|
|
|
|
! echo a | git mergetool a/a/file.txt &&
|
2017-01-10 20:41:53 +00:00
|
|
|
! test -f a/a/file.txt
|
2016-03-10 07:13:58 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool produces no errors when keepBackup is used' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:58 +00:00
|
|
|
git checkout -b test$test_count move-to-c &&
|
2016-03-10 07:13:58 +00: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 21:57:25 +00:00
|
|
|
test_must_be_empty actual &&
|
2017-01-10 20:41:53 +00:00
|
|
|
! test -d a
|
2016-03-10 07:13:59 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool honors tempfile config for deleted files' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:58 +00:00
|
|
|
git checkout -b test$test_count move-to-c &&
|
2016-03-10 07:13:59 +00: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 20:41:53 +00:00
|
|
|
! test -d a
|
2016-03-10 07:13:59 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:53 +00:00
|
|
|
test_when_finished "git clean -fdx" &&
|
2017-01-10 20:41:58 +00:00
|
|
|
git checkout -b test$test_count move-to-c &&
|
2016-03-10 07:13:59 +00:00
|
|
|
test_config mergetool.keepTemporaries true &&
|
|
|
|
test_must_fail git merge move-to-b &&
|
2018-07-02 00:23:42 +00:00
|
|
|
! test_write_lines a n | git mergetool a/a/file.txt &&
|
2016-03-10 07:13:59 +00: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 20:41:53 +00:00
|
|
|
test_cmp expect actual
|
2016-03-10 07:13:58 +00: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 10:00:48 +00:00
|
|
|
test_expect_success 'deleted vs modified submodule' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
|
|
|
mv submod submod-movedaside &&
|
|
|
|
git rm --cached submod &&
|
|
|
|
git commit -m "Submodule deleted from branch" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count.a test$test_count &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "d" | git mergetool file11 file12 &&
|
|
|
|
yes "r" | git mergetool submod &&
|
2014-10-15 08:35:17 +00:00
|
|
|
rmdir submod && mv submod-movedaside submod &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "branch1 submodule" >expect &&
|
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
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 20:41:51 +00:00
|
|
|
git checkout -b test$test_count.b test$test_count &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "d" | git mergetool file11 file12 &&
|
|
|
|
yes "l" | git mergetool submod &&
|
2014-10-15 08:35:17 +00:00
|
|
|
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 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b test$test_count.c main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2017-01-10 20:41:51 +00:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "d" | git mergetool file11 file12 &&
|
|
|
|
yes "r" | git mergetool submod &&
|
2014-10-15 08:35:17 +00:00
|
|
|
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 &&
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b test$test_count.d main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2017-01-10 20:41:51 +00:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "d" | git mergetool file11 file12 &&
|
|
|
|
yes "l" | git mergetool submod &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
2017-01-10 20:41:53 +00: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 10:00:48 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file vs modified submodule' '
|
2017-01-10 20:41:55 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00: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 20:41:51 +00:00
|
|
|
git checkout -b test$test_count.a branch1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "d" | git mergetool file11 file12 &&
|
|
|
|
yes "r" | git mergetool submod &&
|
2014-10-15 08:35:17 +00:00
|
|
|
rmdir submod && mv submod-movedaside submod &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "branch1 submodule" >expect &&
|
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
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 20:41:51 +00:00
|
|
|
git checkout -b test$test_count.b test$test_count &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "d" | git mergetool file11 file12 &&
|
merge tests: expect improved directory/file conflict handling in ort
merge-recursive.c is built on the idea of running unpack_trees() and
then "doing minor touch-ups" to get the result. Unfortunately,
unpack_trees() was run in an update-as-it-goes mode, leading
merge-recursive.c to follow suit and end up with an immediate evaluation
and fix-it-up-as-you-go design. Some things like directory/file
conflicts are not well representable in the index data structure, and
required special extra code to handle. But then when it was discovered
that rename/delete conflicts could also be involved in directory/file
conflicts, the special directory/file conflict handling code had to be
copied to the rename/delete codepath. ...and then it had to be copied
for modify/delete, and for rename/rename(1to2) conflicts, ...and yet it
still missed some. Further, when it was discovered that there were also
file/submodule conflicts and submodule/directory conflicts, we needed to
copy the special submodule handling code to all the special cases
throughout the codebase.
And then it was discovered that our handling of directory/file conflicts
was suboptimal because it would create untracked files to store the
contents of the conflicting file, which would not be cleaned up if
someone were to run a 'git merge --abort' or 'git rebase --abort'. It
was also difficult or scary to try to add or remove the index entries
corresponding to these files given the directory/file conflict in the
index. But changing merge-recursive.c to handle these correctly was a
royal pain because there were so many sites in the code with similar but
not identical code for handling directory/file/submodule conflicts that
would all need to be updated.
I have worked hard to push all directory/file/submodule conflict
handling in merge-ort through a single codepath, and avoid creating
untracked files for storing tracked content (it does record things at
alternate paths, but makes sure they have higher-order stages in the
index).
Since updating merge-recursive is too much work and we don't want to
destabilize it, instead update the testsuite to have different
expectations for relevant directory/file/submodule conflict tests.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-26 17:01:37 +00:00
|
|
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
|
|
|
then
|
|
|
|
yes "c" | git mergetool submod~HEAD &&
|
|
|
|
git rm submod &&
|
|
|
|
git mv submod~HEAD submod
|
|
|
|
else
|
|
|
|
yes "l" | git mergetool submod
|
|
|
|
fi &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "not a submodule" >expect &&
|
|
|
|
test_cmp expect submod &&
|
2014-10-15 08:35:17 +00:00
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by keeping file" &&
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b test$test_count.c main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
rmdir submod && mv submod-movedaside submod &&
|
|
|
|
test ! -e submod.orig &&
|
|
|
|
git submodule update -N &&
|
2017-01-10 20:41:51 +00:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "d" | git mergetool file11 file12 &&
|
merge tests: expect improved directory/file conflict handling in ort
merge-recursive.c is built on the idea of running unpack_trees() and
then "doing minor touch-ups" to get the result. Unfortunately,
unpack_trees() was run in an update-as-it-goes mode, leading
merge-recursive.c to follow suit and end up with an immediate evaluation
and fix-it-up-as-you-go design. Some things like directory/file
conflicts are not well representable in the index data structure, and
required special extra code to handle. But then when it was discovered
that rename/delete conflicts could also be involved in directory/file
conflicts, the special directory/file conflict handling code had to be
copied to the rename/delete codepath. ...and then it had to be copied
for modify/delete, and for rename/rename(1to2) conflicts, ...and yet it
still missed some. Further, when it was discovered that there were also
file/submodule conflicts and submodule/directory conflicts, we needed to
copy the special submodule handling code to all the special cases
throughout the codebase.
And then it was discovered that our handling of directory/file conflicts
was suboptimal because it would create untracked files to store the
contents of the conflicting file, which would not be cleaned up if
someone were to run a 'git merge --abort' or 'git rebase --abort'. It
was also difficult or scary to try to add or remove the index entries
corresponding to these files given the directory/file conflict in the
index. But changing merge-recursive.c to handle these correctly was a
royal pain because there were so many sites in the code with similar but
not identical code for handling directory/file/submodule conflicts that
would all need to be updated.
I have worked hard to push all directory/file/submodule conflict
handling in merge-ort through a single codepath, and avoid creating
untracked files for storing tracked content (it does record things at
alternate paths, but makes sure they have higher-order stages in the
index).
Since updating merge-recursive is too much work and we don't want to
destabilize it, instead update the testsuite to have different
expectations for relevant directory/file/submodule conflict tests.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-26 17:01:37 +00:00
|
|
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
|
|
|
then
|
|
|
|
mv submod submod.orig &&
|
|
|
|
git rm --cached submod &&
|
|
|
|
yes "c" | git mergetool submod~test19 &&
|
|
|
|
git mv submod~test19 submod
|
|
|
|
else
|
|
|
|
yes "r" | git mergetool submod
|
|
|
|
fi &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -d submod.orig &&
|
|
|
|
git submodule update -N &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "not a submodule" >expect &&
|
|
|
|
test_cmp expect submod &&
|
2014-10-15 08:35:17 +00:00
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git commit -m "Merge resolved by keeping file" &&
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b test$test_count.d main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
rmdir submod && mv submod.orig submod &&
|
|
|
|
git submodule update -N &&
|
2017-01-10 20:41:51 +00:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
|
|
|
|
yes "" | git mergetool both &&
|
|
|
|
yes "d" | git mergetool file11 file12 &&
|
|
|
|
yes "l" | git mergetool submod &&
|
merge tests: expect improved directory/file conflict handling in ort
merge-recursive.c is built on the idea of running unpack_trees() and
then "doing minor touch-ups" to get the result. Unfortunately,
unpack_trees() was run in an update-as-it-goes mode, leading
merge-recursive.c to follow suit and end up with an immediate evaluation
and fix-it-up-as-you-go design. Some things like directory/file
conflicts are not well representable in the index data structure, and
required special extra code to handle. But then when it was discovered
that rename/delete conflicts could also be involved in directory/file
conflicts, the special directory/file conflict handling code had to be
copied to the rename/delete codepath. ...and then it had to be copied
for modify/delete, and for rename/rename(1to2) conflicts, ...and yet it
still missed some. Further, when it was discovered that there were also
file/submodule conflicts and submodule/directory conflicts, we needed to
copy the special submodule handling code to all the special cases
throughout the codebase.
And then it was discovered that our handling of directory/file conflicts
was suboptimal because it would create untracked files to store the
contents of the conflicting file, which would not be cleaned up if
someone were to run a 'git merge --abort' or 'git rebase --abort'. It
was also difficult or scary to try to add or remove the index entries
corresponding to these files given the directory/file conflict in the
index. But changing merge-recursive.c to handle these correctly was a
royal pain because there were so many sites in the code with similar but
not identical code for handling directory/file/submodule conflicts that
would all need to be updated.
I have worked hard to push all directory/file/submodule conflict
handling in merge-ort through a single codepath, and avoid creating
untracked files for storing tracked content (it does record things at
alternate paths, but makes sure they have higher-order stages in the
index).
Since updating merge-recursive is too much work and we don't want to
destabilize it, instead update the testsuite to have different
expectations for relevant directory/file/submodule conflict tests.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-26 17:01:37 +00:00
|
|
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
|
|
|
then
|
|
|
|
yes "d" | git mergetool submod~test19
|
|
|
|
fi &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
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 10:00:48 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule in subdirectory' '
|
2017-01-10 20:41:55 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00: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 20:41:53 +00:00
|
|
|
test_when_finished "rm -rf subdir/subdir_module" &&
|
2014-10-15 08:35:17 +00: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 20:41:51 +00:00
|
|
|
git checkout -b test$test_count.a test$test_count &&
|
2014-10-15 08:35:17 +00: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 10:00:48 +00:00
|
|
|
(
|
|
|
|
cd subdir/subdir_module &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git checkout -b super10.a &&
|
2017-01-10 20:41:51 +00:00
|
|
|
echo test$test_count.a >file15 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git add file15 &&
|
|
|
|
git commit -m "on branch 10.a"
|
|
|
|
) &&
|
|
|
|
git add subdir/subdir_module &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git commit -m "change submodule in subdirectory on test$test_count.a" &&
|
2014-10-15 08:35:17 +00:00
|
|
|
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count.b test$test_count &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
|
|
|
(
|
|
|
|
cd subdir/subdir_module &&
|
|
|
|
git checkout -b super10.b &&
|
2017-01-10 20:41:51 +00:00
|
|
|
echo test$test_count.b >file15 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git add file15 &&
|
|
|
|
git commit -m "on branch 10.b"
|
|
|
|
) &&
|
|
|
|
git add subdir/subdir_module &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git commit -m "change submodule in subdirectory on test$test_count.b" &&
|
2014-10-15 08:35:17 +00:00
|
|
|
|
2019-04-24 22:46:57 +00:00
|
|
|
test_must_fail git merge test$test_count.a &&
|
2014-10-15 08:35:17 +00:00
|
|
|
(
|
|
|
|
cd subdir &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "l" | git mergetool subdir_module
|
2014-10-15 08:35:17 +00:00
|
|
|
) &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "test$test_count.b" >expect &&
|
|
|
|
test_cmp expect subdir/subdir_module/file15 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "test$test_count.b" >expect &&
|
|
|
|
test_cmp expect subdir/subdir_module/file15 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git reset --hard &&
|
|
|
|
git submodule update -N &&
|
|
|
|
|
2019-04-24 22:46:57 +00:00
|
|
|
test_must_fail git merge test$test_count.a &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "r" | git mergetool subdir/subdir_module &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "test$test_count.b" >expect &&
|
|
|
|
test_cmp expect subdir/subdir_module/file15 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "test$test_count.a" >expect &&
|
|
|
|
test_cmp expect subdir/subdir_module/file15 &&
|
2017-01-10 20:41:53 +00: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 10:00:48 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'directory vs modified submodule' '
|
2017-01-10 20:41:55 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:17 +00: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" &&
|
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "l" | git mergetool submod &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "not a submodule" >expect &&
|
|
|
|
test_cmp expect submod/file16 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
rm -rf submod.orig &&
|
|
|
|
|
2017-01-10 20:41:59 +00:00
|
|
|
git reset --hard &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
test ! -e submod.orig &&
|
merge tests: expect improved directory/file conflict handling in ort
merge-recursive.c is built on the idea of running unpack_trees() and
then "doing minor touch-ups" to get the result. Unfortunately,
unpack_trees() was run in an update-as-it-goes mode, leading
merge-recursive.c to follow suit and end up with an immediate evaluation
and fix-it-up-as-you-go design. Some things like directory/file
conflicts are not well representable in the index data structure, and
required special extra code to handle. But then when it was discovered
that rename/delete conflicts could also be involved in directory/file
conflicts, the special directory/file conflict handling code had to be
copied to the rename/delete codepath. ...and then it had to be copied
for modify/delete, and for rename/rename(1to2) conflicts, ...and yet it
still missed some. Further, when it was discovered that there were also
file/submodule conflicts and submodule/directory conflicts, we needed to
copy the special submodule handling code to all the special cases
throughout the codebase.
And then it was discovered that our handling of directory/file conflicts
was suboptimal because it would create untracked files to store the
contents of the conflicting file, which would not be cleaned up if
someone were to run a 'git merge --abort' or 'git rebase --abort'. It
was also difficult or scary to try to add or remove the index entries
corresponding to these files given the directory/file conflict in the
index. But changing merge-recursive.c to handle these correctly was a
royal pain because there were so many sites in the code with similar but
not identical code for handling directory/file/submodule conflicts that
would all need to be updated.
I have worked hard to push all directory/file/submodule conflict
handling in merge-ort through a single codepath, and avoid creating
untracked files for storing tracked content (it does record things at
alternate paths, but makes sure they have higher-order stages in the
index).
Since updating merge-recursive is too much work and we don't want to
destabilize it, instead update the testsuite to have different
expectations for relevant directory/file/submodule conflict tests.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-26 17:01:37 +00:00
|
|
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
|
|
|
then
|
2020-11-18 23:44:40 +00:00
|
|
|
yes "r" | git mergetool submod~main &&
|
merge tests: expect improved directory/file conflict handling in ort
merge-recursive.c is built on the idea of running unpack_trees() and
then "doing minor touch-ups" to get the result. Unfortunately,
unpack_trees() was run in an update-as-it-goes mode, leading
merge-recursive.c to follow suit and end up with an immediate evaluation
and fix-it-up-as-you-go design. Some things like directory/file
conflicts are not well representable in the index data structure, and
required special extra code to handle. But then when it was discovered
that rename/delete conflicts could also be involved in directory/file
conflicts, the special directory/file conflict handling code had to be
copied to the rename/delete codepath. ...and then it had to be copied
for modify/delete, and for rename/rename(1to2) conflicts, ...and yet it
still missed some. Further, when it was discovered that there were also
file/submodule conflicts and submodule/directory conflicts, we needed to
copy the special submodule handling code to all the special cases
throughout the codebase.
And then it was discovered that our handling of directory/file conflicts
was suboptimal because it would create untracked files to store the
contents of the conflicting file, which would not be cleaned up if
someone were to run a 'git merge --abort' or 'git rebase --abort'. It
was also difficult or scary to try to add or remove the index entries
corresponding to these files given the directory/file conflict in the
index. But changing merge-recursive.c to handle these correctly was a
royal pain because there were so many sites in the code with similar but
not identical code for handling directory/file/submodule conflicts that
would all need to be updated.
I have worked hard to push all directory/file/submodule conflict
handling in merge-ort through a single codepath, and avoid creating
untracked files for storing tracked content (it does record things at
alternate paths, but makes sure they have higher-order stages in the
index).
Since updating merge-recursive is too much work and we don't want to
destabilize it, instead update the testsuite to have different
expectations for relevant directory/file/submodule conflict tests.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-26 17:01:37 +00:00
|
|
|
git mv submod submod.orig &&
|
2020-11-18 23:44:40 +00:00
|
|
|
git mv submod~main submod
|
merge tests: expect improved directory/file conflict handling in ort
merge-recursive.c is built on the idea of running unpack_trees() and
then "doing minor touch-ups" to get the result. Unfortunately,
unpack_trees() was run in an update-as-it-goes mode, leading
merge-recursive.c to follow suit and end up with an immediate evaluation
and fix-it-up-as-you-go design. Some things like directory/file
conflicts are not well representable in the index data structure, and
required special extra code to handle. But then when it was discovered
that rename/delete conflicts could also be involved in directory/file
conflicts, the special directory/file conflict handling code had to be
copied to the rename/delete codepath. ...and then it had to be copied
for modify/delete, and for rename/rename(1to2) conflicts, ...and yet it
still missed some. Further, when it was discovered that there were also
file/submodule conflicts and submodule/directory conflicts, we needed to
copy the special submodule handling code to all the special cases
throughout the codebase.
And then it was discovered that our handling of directory/file conflicts
was suboptimal because it would create untracked files to store the
contents of the conflicting file, which would not be cleaned up if
someone were to run a 'git merge --abort' or 'git rebase --abort'. It
was also difficult or scary to try to add or remove the index entries
corresponding to these files given the directory/file conflict in the
index. But changing merge-recursive.c to handle these correctly was a
royal pain because there were so many sites in the code with similar but
not identical code for handling directory/file/submodule conflicts that
would all need to be updated.
I have worked hard to push all directory/file/submodule conflict
handling in merge-ort through a single codepath, and avoid creating
untracked files for storing tracked content (it does record things at
alternate paths, but makes sure they have higher-order stages in the
index).
Since updating merge-recursive is too much work and we don't want to
destabilize it, instead update the testsuite to have different
expectations for relevant directory/file/submodule conflict tests.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-26 17:01:37 +00:00
|
|
|
else
|
|
|
|
yes "r" | git mergetool submod
|
|
|
|
fi &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -d submod.orig &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "not a submodule" >expect &&
|
|
|
|
test_cmp expect submod.orig/file16 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
rm -r submod.orig &&
|
|
|
|
mv submod-movedaside/.git submod &&
|
|
|
|
( cd submod && git clean -f && git reset --hard ) &&
|
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2017-01-10 20:41:59 +00:00
|
|
|
git reset --hard &&
|
|
|
|
rm -rf submod-movedaside &&
|
2014-10-15 08:35:17 +00:00
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git checkout -b test$test_count.c main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2017-01-10 20:41:51 +00:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "l" | git mergetool submod &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo "main submodule" >expect &&
|
2019-06-12 16:33:46 +00:00
|
|
|
test_cmp expect submod/bar &&
|
2014-10-15 08:35:17 +00:00
|
|
|
|
2017-01-10 20:41:59 +00:00
|
|
|
git reset --hard &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git submodule update -N &&
|
2017-01-10 20:41:51 +00:00
|
|
|
test_must_fail git merge test$test_count &&
|
2014-10-15 08:35:17 +00:00
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
test ! -e submod.orig &&
|
2019-06-10 08:58:58 +00:00
|
|
|
yes "r" | git mergetool submod &&
|
2019-06-12 16:33:46 +00:00
|
|
|
echo "not a submodule" >expect &&
|
|
|
|
test_cmp expect submod/file16 &&
|
2014-10-15 08:35:17 +00:00
|
|
|
|
2020-11-18 23:44:40 +00:00
|
|
|
git reset --hard main &&
|
2014-10-15 08:35:17 +00: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 10:00:48 +00:00
|
|
|
'
|
|
|
|
|
2012-01-20 07:47:35 +00:00
|
|
|
test_expect_success 'file with no base' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git mergetool --no-prompt --tool mybase -- both &&
|
2018-07-27 17:48:11 +00:00
|
|
|
test_must_be_empty both
|
2012-01-20 07:47:35 +00:00
|
|
|
'
|
|
|
|
|
2012-09-25 07:48:11 +00:00
|
|
|
test_expect_success 'custom commands override built-ins' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:20 +00:00
|
|
|
test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
|
|
|
|
test_config mergetool.defaults.trustExitCode true &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:17 +00:00
|
|
|
git mergetool --no-prompt --tool defaults -- both &&
|
2020-11-18 23:44:40 +00:00
|
|
|
echo main both added >expected &&
|
2017-10-06 19:00:06 +00:00
|
|
|
test_cmp expected both
|
2012-09-25 07:48:11 +00:00
|
|
|
'
|
|
|
|
|
2014-10-15 08:35:19 +00:00
|
|
|
test_expect_success 'filenames seen by tools start with ./' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:19 +00:00
|
|
|
test_config mergetool.writeToTemp false &&
|
|
|
|
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
|
|
|
|
test_config mergetool.myecho.trustExitCode true &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:19 +00:00
|
|
|
git mergetool --no-prompt --tool myecho -- both >actual &&
|
2019-04-24 22:46:57 +00:00
|
|
|
grep ^\./both_LOCAL_ actual
|
2014-10-15 08:35:19 +00:00
|
|
|
'
|
|
|
|
|
2016-07-02 19:01:51 +00:00
|
|
|
test_lazy_prereq MKTEMP '
|
|
|
|
tempdir=$(mktemp -d -t foo.XXXXXX) &&
|
2016-11-27 06:34:45 +00:00
|
|
|
test -d "$tempdir" &&
|
|
|
|
rmdir "$tempdir"
|
2016-07-02 19:01:51 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:51 +00:00
|
|
|
git checkout -b test$test_count branch1 &&
|
2014-10-15 08:35:19 +00:00
|
|
|
test_config mergetool.writeToTemp true &&
|
|
|
|
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
|
|
|
|
test_config mergetool.myecho.trustExitCode true &&
|
2020-11-18 23:44:40 +00:00
|
|
|
test_must_fail git merge main &&
|
2014-10-15 08:35:19 +00:00
|
|
|
git mergetool --no-prompt --tool myecho -- both >actual &&
|
2019-04-24 22:46:57 +00:00
|
|
|
! grep ^\./both_LOCAL_ actual &&
|
|
|
|
grep /both_LOCAL_ actual
|
2014-10-15 08:35:19 +00:00
|
|
|
'
|
|
|
|
|
2016-10-07 23:58:05 +00:00
|
|
|
test_expect_success 'diff.orderFile configuration is honored' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:57 +00:00
|
|
|
git checkout -b test$test_count order-file-side2 &&
|
2016-10-07 23:58:05 +00: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 20:42:02 +00:00
|
|
|
|
|
|
|
# make sure "order-file" that is ambiguous between
|
|
|
|
# rev and path is understood correctly.
|
|
|
|
git branch order-file HEAD &&
|
|
|
|
|
2016-10-07 23:58:05 +00:00
|
|
|
git mergetool --no-prompt --tool myecho >output &&
|
|
|
|
git grep --no-index -h -A2 Merging: output >actual &&
|
2017-01-10 20:41:53 +00:00
|
|
|
test_cmp expect actual
|
2016-10-07 23:58:05 +00:00
|
|
|
'
|
2016-10-08 00:01:30 +00:00
|
|
|
test_expect_success 'mergetool -Oorder-file is honored' '
|
2017-01-10 20:41:59 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
2017-01-10 20:41:58 +00:00
|
|
|
git checkout -b test$test_count order-file-side2 &&
|
2016-10-08 00:01:30 +00:00
|
|
|
test_config diff.orderFile order-file &&
|
|
|
|
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
|
|
|
|
test_config mergetool.myecho.trustExitCode true &&
|
2017-01-10 20:41:54 +00:00
|
|
|
echo b >order-file &&
|
|
|
|
echo a >>order-file &&
|
2016-10-08 00:01:30 +00: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 20:41:59 +00:00
|
|
|
git reset --hard &&
|
2016-10-08 00:01:30 +00: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 20:41:53 +00:00
|
|
|
test_cmp expect actual
|
2016-10-08 00:01:30 +00:00
|
|
|
'
|
2016-10-07 23:58:05 +00:00
|
|
|
|
mergetool--lib: fix '--tool-help' to correctly show available tools
Commit 83bbf9b92e (mergetool--lib: improve support for vimdiff-style tool
variants, 2020-07-29) introduced a regression in the output of `git mergetool
--tool-help` and `git difftool --tool-help` [1].
In function 'show_tool_names' in git-mergetool--lib.sh, we loop over the
supported mergetools and their variants and accumulate them in the variable
'variants', separating them with a literal '\n'.
The code then uses 'echo $variants' to turn these '\n' into newlines, but this
behaviour is not portable, it just happens to work in some shells, like
dash(1)'s 'echo' builtin.
For shells in which 'echo' does not turn '\n' into newlines, the end
result is that the only tools that are shown are the existing variants
(except the last variant alphabetically), since the variants are
separated by actual newlines in '$variants' because of the several
'echo' calls in mergetools/{bc,vimdiff}::list_tool_variants.
Fix this bug by embedding an actual line feed into `variants` in
show_tool_names(). While at it, replace `sort | uniq` by `sort -u`.
To prevent future regressions, add a simple test that checks that a few
known tools are correctly shown (let's avoid counting the total number
of tools to lessen the maintenance burden when new tools are added or if
'--tool-help' learns additional logic, like hiding tools depending on
the current platform).
[1] https://lore.kernel.org/git/CADtb9DyozjgAsdFYL8fFBEWmq7iz4=prZYVUdH9W-J5CKVS4OA@mail.gmail.com/
Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>
Based-on-patch-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-07 01:09:05 +00:00
|
|
|
test_expect_success 'mergetool --tool-help shows recognized tools' '
|
|
|
|
# Check a few known tools are correctly shown
|
|
|
|
git mergetool --tool-help >mergetools &&
|
|
|
|
grep vimdiff mergetools &&
|
|
|
|
grep vimdiff3 mergetools &&
|
|
|
|
grep gvimdiff2 mergetools &&
|
|
|
|
grep araxis mergetools &&
|
|
|
|
grep xxdiff mergetools &&
|
|
|
|
grep meld mergetools
|
|
|
|
'
|
|
|
|
|
2021-02-09 20:07:10 +00:00
|
|
|
test_expect_success 'mergetool hideResolved' '
|
|
|
|
test_config mergetool.hideResolved true &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
2021-02-18 01:21:41 +00:00
|
|
|
git checkout -b test${test_count}_b main &&
|
2021-02-09 20:07:10 +00:00
|
|
|
test_write_lines >file1 base "" a &&
|
|
|
|
git commit -a -m "base" &&
|
|
|
|
test_write_lines >file1 base "" c &&
|
|
|
|
git commit -a -m "remote update" &&
|
|
|
|
git checkout -b test${test_count}_a HEAD~ &&
|
|
|
|
test_write_lines >file1 local "" b &&
|
|
|
|
git commit -a -m "local update" &&
|
|
|
|
test_must_fail git merge test${test_count}_b &&
|
|
|
|
yes "" | git mergetool file1 &&
|
|
|
|
test_write_lines >expect local "" c &&
|
|
|
|
test_cmp expect file1 &&
|
|
|
|
git commit -m "test resolved with mergetool"
|
|
|
|
'
|
|
|
|
|
2008-02-21 23:31:56 +00:00
|
|
|
test_done
|