2008-02-22 07:31:56 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2008 Charles Bailey
|
|
|
|
#
|
|
|
|
|
2008-09-03 16:59:33 +08:00
|
|
|
test_description='git mergetool
|
2008-02-22 07:31:56 +08:00
|
|
|
|
|
|
|
Testing basic merge tool invocation'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2009-01-31 07:20:10 +08: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 07:31:56 +08:00
|
|
|
test_expect_success 'setup' '
|
2010-08-17 17:22:46 +08:00
|
|
|
git config rerere.enabled true &&
|
2008-02-22 07:31:56 +08:00
|
|
|
echo master >file1 &&
|
2011-02-16 18:47:45 +08:00
|
|
|
echo master file11 >file11 &&
|
|
|
|
echo master file12 >file12 &&
|
|
|
|
echo master file13 >file13 &&
|
|
|
|
echo master file14 >file14 &&
|
2009-01-31 07:20:10 +08:00
|
|
|
mkdir subdir &&
|
|
|
|
echo master sub >subdir/file3 &&
|
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 18:00:48 +08: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 file1[1-4] subdir/file3 .gitmodules submod &&
|
2011-02-16 18:47:45 +08:00
|
|
|
git commit -m "add initial versions" &&
|
2009-01-31 07:20:10 +08:00
|
|
|
|
2008-02-22 07:31:56 +08:00
|
|
|
git checkout -b branch1 master &&
|
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 18:00:48 +08:00
|
|
|
git submodule update -N &&
|
2008-02-22 07:31:56 +08:00
|
|
|
echo branch1 change >file1 &&
|
|
|
|
echo branch1 newfile >file2 &&
|
2011-02-16 18:47:45 +08:00
|
|
|
echo branch1 change file11 >file11 &&
|
|
|
|
echo branch1 change file13 >file13 &&
|
2009-01-31 07:20:10 +08:00
|
|
|
echo branch1 sub >subdir/file3 &&
|
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 18:00:48 +08:00
|
|
|
(
|
|
|
|
cd submod &&
|
|
|
|
echo branch1 submodule >bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m "Add bar on branch1" &&
|
|
|
|
git checkout -b submod-branch1
|
|
|
|
) &&
|
|
|
|
git add file1 file11 file13 file2 subdir/file3 submod &&
|
2011-02-16 18:47:45 +08:00
|
|
|
git rm file12 &&
|
2008-02-22 07:31:56 +08:00
|
|
|
git commit -m "branch1 changes" &&
|
2009-01-31 07:20:10 +08:00
|
|
|
|
2008-02-22 07:31:56 +08:00
|
|
|
git checkout master &&
|
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 18:00:48 +08:00
|
|
|
git submodule update -N &&
|
2008-02-22 07:31:56 +08:00
|
|
|
echo master updated >file1 &&
|
|
|
|
echo master new >file2 &&
|
2011-02-16 18:47:45 +08:00
|
|
|
echo master updated file12 >file12 &&
|
|
|
|
echo master updated file14 >file14 &&
|
2009-01-31 07:20:10 +08:00
|
|
|
echo master new sub >subdir/file3 &&
|
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 18:00:48 +08:00
|
|
|
(
|
|
|
|
cd submod &&
|
|
|
|
echo master submodule >bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m "Add bar on master" &&
|
|
|
|
git checkout -b submod-master
|
|
|
|
) &&
|
|
|
|
git add file1 file12 file14 file2 subdir/file3 submod &&
|
2011-02-16 18:47:45 +08:00
|
|
|
git rm file11 &&
|
2009-01-31 07:20:10 +08:00
|
|
|
git commit -m "master updates" &&
|
2008-02-22 07:31:56 +08:00
|
|
|
|
|
|
|
git config merge.tool mytool &&
|
|
|
|
git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
|
2009-01-31 07:20:10 +08:00
|
|
|
git config mergetool.mytool.trustExitCode true
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'custom mergetool' '
|
|
|
|
git checkout -b test1 branch1 &&
|
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 18:00:48 +08:00
|
|
|
git submodule update -N &&
|
2008-07-12 23:47:52 +08:00
|
|
|
test_must_fail git merge master >/dev/null 2>&1 &&
|
2009-01-31 07:20:10 +08:00
|
|
|
( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
|
2011-02-16 18:47:45 +08:00
|
|
|
( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
|
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 18:00:48 +08:00
|
|
|
( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
|
2008-02-22 07:31:56 +08:00
|
|
|
test "$(cat file1)" = "master updated" &&
|
|
|
|
test "$(cat file2)" = "master new" &&
|
2009-01-31 07:20:10 +08:00
|
|
|
test "$(cat subdir/file3)" = "master new sub" &&
|
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 18:00:48 +08:00
|
|
|
test "$(cat submod/bar)" = "branch1 submodule" &&
|
2009-01-22 06:57:48 +08:00
|
|
|
git commit -m "branch1 resolved with mergetool"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool crlf' '
|
|
|
|
git config core.autocrlf true &&
|
2010-10-31 09:46:54 +08:00
|
|
|
git checkout -b test2 branch1 &&
|
2009-01-22 06:57:48 +08:00
|
|
|
test_must_fail git merge master >/dev/null 2>&1 &&
|
2009-01-31 07:20:10 +08:00
|
|
|
( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
|
2011-02-16 18:47:45 +08:00
|
|
|
( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
|
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 18:00:48 +08:00
|
|
|
( yes "r" | git mergetool submod >/dev/null 2>&1 ) &&
|
2009-01-22 06:57:48 +08:00
|
|
|
test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
|
|
|
|
test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
|
2009-01-31 07:20:10 +08:00
|
|
|
test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
|
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 18:00:48 +08:00
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
2009-01-31 07:20:10 +08:00
|
|
|
git commit -m "branch1 resolved with mergetool - autocrlf" &&
|
|
|
|
git config core.autocrlf false &&
|
|
|
|
git reset --hard
|
|
|
|
'
|
|
|
|
|
2009-01-31 07:20:11 +08:00
|
|
|
test_expect_success 'mergetool in subdir' '
|
2010-08-24 10:37:24 +08:00
|
|
|
git checkout -b test3 branch1 &&
|
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 18:00:48 +08:00
|
|
|
git submodule update -N &&
|
2010-08-24 10:37:24 +08:00
|
|
|
(
|
|
|
|
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 07:31:56 +08:00
|
|
|
'
|
|
|
|
|
2010-08-17 17:22:46 +08:00
|
|
|
test_expect_success 'mergetool on file in parent dir' '
|
2010-08-24 10:37:24 +08:00
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
|
2011-02-16 18:47:45 +08:00
|
|
|
( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) &&
|
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 18:00:48 +08:00
|
|
|
( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
|
2010-08-24 10:37:24 +08:00
|
|
|
test "$(cat ../file1)" = "master updated" &&
|
|
|
|
test "$(cat ../file2)" = "master new" &&
|
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 18:00:48 +08:00
|
|
|
test "$(cat ../submod/bar)" = "branch1 submodule" &&
|
2010-08-24 10:37:24 +08:00
|
|
|
git commit -m "branch1 resolved with mergetool - subdir"
|
|
|
|
)
|
2010-08-17 17:22:46 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool skips autoresolved' '
|
|
|
|
git checkout -b test4 branch1 &&
|
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 18:00:48 +08:00
|
|
|
git submodule update -N &&
|
2010-08-17 17:22:46 +08:00
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
2011-02-16 18:47:45 +08:00
|
|
|
( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
|
|
|
|
( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
|
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 18:00:48 +08:00
|
|
|
( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
|
2010-08-17 17:22:46 +08:00
|
|
|
output="$(git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git reset --hard
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'mergetool merges all from subdir' '
|
2010-08-24 10:37:24 +08:00
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
git config rerere.enabled false &&
|
|
|
|
test_must_fail git merge master &&
|
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 18:00:48 +08:00
|
|
|
( yes "r" | git mergetool ../submod ) &&
|
2011-02-16 18:47:45 +08:00
|
|
|
( yes "d" "d" | git mergetool --no-prompt ) &&
|
2010-08-24 10:37:24 +08:00
|
|
|
test "$(cat ../file1)" = "master updated" &&
|
|
|
|
test "$(cat ../file2)" = "master new" &&
|
|
|
|
test "$(cat file3)" = "master new sub" &&
|
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 18:00:48 +08:00
|
|
|
( cd .. && git submodule update -N ) &&
|
|
|
|
test "$(cat ../submod/bar)" = "master submodule" &&
|
2010-08-24 10:37:24 +08:00
|
|
|
git commit -m "branch2 resolved by mergetool from subdir"
|
|
|
|
)
|
2010-08-17 17:22:46 +08:00
|
|
|
'
|
2009-01-31 07:20:10 +08:00
|
|
|
|
2011-02-16 18:47:45 +08:00
|
|
|
test_expect_success 'mergetool skips resolved paths when rerere is active' '
|
|
|
|
git config rerere.enabled true &&
|
|
|
|
rm -rf .git/rr-cache &&
|
|
|
|
git checkout -b test5 branch1
|
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 18:00:48 +08:00
|
|
|
git submodule update -N &&
|
2011-02-16 18:47:45 +08:00
|
|
|
test_must_fail git merge master >/dev/null 2>&1 &&
|
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 18:00:48 +08:00
|
|
|
( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&
|
2011-02-16 18:47:45 +08:00
|
|
|
( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) &&
|
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 18:00:48 +08:00
|
|
|
git submodule update -N &&
|
2011-02-16 18:47:45 +08:00
|
|
|
output="$(yes "n" | git mergetool --no-prompt)" &&
|
|
|
|
test "$output" = "No files need merging" &&
|
|
|
|
git reset --hard
|
|
|
|
'
|
|
|
|
|
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 18:00:48 +08:00
|
|
|
test_expect_success 'deleted vs modified submodule' '
|
|
|
|
git checkout -b test6 branch1 &&
|
|
|
|
git submodule update -N &&
|
|
|
|
mv submod submod-movedaside &&
|
|
|
|
git rm submod &&
|
|
|
|
git commit -m "Submodule deleted from branch" &&
|
|
|
|
git checkout -b test6.a test6 &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 subdir/file3 >/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 &&
|
|
|
|
git checkout -b test6.b test6 &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 subdir/file3 >/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 &&
|
|
|
|
git checkout -b test6.c master &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge test6 &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 subdir/file3 >/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 &&
|
|
|
|
|
|
|
|
git checkout -b test6.d master &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge test6 &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 subdir/file3 >/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" &&
|
|
|
|
git reset --hard HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file vs modified submodule' '
|
|
|
|
git checkout -b test7 branch1 &&
|
|
|
|
git submodule update -N &&
|
|
|
|
mv submod submod-movedaside &&
|
|
|
|
git rm submod &&
|
|
|
|
echo not a submodule >submod &&
|
|
|
|
git add submod &&
|
|
|
|
git commit -m "Submodule path becomes file" &&
|
|
|
|
git checkout -b test7.a branch1 &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 subdir/file3 >/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 &&
|
|
|
|
git checkout -b test7.b test7 &&
|
|
|
|
test_must_fail git merge master &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 subdir/file3 >/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" &&
|
|
|
|
|
|
|
|
git checkout -b test7.c master &&
|
|
|
|
rmdir submod && mv submod-movedaside submod &&
|
|
|
|
test ! -e submod.orig &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge test7 &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 subdir/file3 >/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" &&
|
|
|
|
|
|
|
|
git checkout -b test7.d master &&
|
|
|
|
rmdir submod && mv submod.orig submod &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge test7 &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "" | git mergetool file1 file2 subdir/file3 >/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"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule in subdirectory' '
|
|
|
|
git checkout -b test10 branch1 &&
|
|
|
|
git submodule update -N &&
|
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
test_create_repo subdir_module &&
|
|
|
|
(
|
|
|
|
cd subdir_module &&
|
|
|
|
: >file15 &&
|
|
|
|
git add file15 &&
|
|
|
|
git commit -m "add initial versions"
|
|
|
|
)
|
|
|
|
) &&
|
|
|
|
git submodule add git://example.com/subsubmodule subdir/subdir_module &&
|
|
|
|
git add subdir/subdir_module &&
|
|
|
|
git commit -m "add submodule in subdirectory" &&
|
|
|
|
|
|
|
|
git checkout -b test10.a test10 &&
|
|
|
|
git submodule update -N &&
|
|
|
|
(
|
|
|
|
cd subdir/subdir_module &&
|
|
|
|
git checkout -b super10.a &&
|
|
|
|
echo test10.a >file15 &&
|
|
|
|
git add file15 &&
|
|
|
|
git commit -m "on branch 10.a"
|
|
|
|
) &&
|
|
|
|
git add subdir/subdir_module &&
|
|
|
|
git commit -m "change submodule in subdirectory on test10.a" &&
|
|
|
|
|
|
|
|
git checkout -b test10.b test10 &&
|
|
|
|
git submodule update -N &&
|
|
|
|
(
|
|
|
|
cd subdir/subdir_module &&
|
|
|
|
git checkout -b super10.b &&
|
|
|
|
echo test10.b >file15 &&
|
|
|
|
git add file15 &&
|
|
|
|
git commit -m "on branch 10.b"
|
|
|
|
) &&
|
|
|
|
git add subdir/subdir_module &&
|
|
|
|
git commit -m "change submodule in subdirectory on test10.b" &&
|
|
|
|
|
|
|
|
test_must_fail git merge test10.a >/dev/null 2>&1 &&
|
|
|
|
(
|
|
|
|
cd subdir &&
|
|
|
|
( yes "l" | git mergetool subdir_module )
|
|
|
|
) &&
|
|
|
|
test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
|
|
|
|
git reset --hard &&
|
|
|
|
git submodule update -N &&
|
|
|
|
|
|
|
|
test_must_fail git merge test10.a >/dev/null 2>&1 &&
|
|
|
|
( yes "r" | git mergetool subdir/subdir_module ) &&
|
|
|
|
test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat subdir/subdir_module/file15)" = "test10.a" &&
|
|
|
|
git commit -m "branch1 resolved with mergetool" &&
|
|
|
|
rm -rf subdir/subdir_module
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'directory vs modified submodule' '
|
|
|
|
git checkout -b test11 branch1 &&
|
|
|
|
mv submod submod-movedaside &&
|
|
|
|
git rm 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 &&
|
|
|
|
|
|
|
|
git reset --hard &&
|
|
|
|
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" &&
|
|
|
|
git reset --hard && rm -rf submod-movedaside &&
|
|
|
|
|
|
|
|
git checkout -b test11.c master &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge test11 &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
( yes "l" | git mergetool submod ) &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test "$(cat submod/bar)" = "master submodule" &&
|
|
|
|
|
|
|
|
git reset --hard &&
|
|
|
|
git submodule update -N &&
|
|
|
|
test_must_fail git merge test11 &&
|
|
|
|
test -n "$(git ls-files -u)" &&
|
|
|
|
test ! -e submod.orig &&
|
|
|
|
( yes "r" | git mergetool submod ) &&
|
|
|
|
test "$(cat submod/file16)" = "not a submodule" &&
|
|
|
|
|
|
|
|
git reset --hard master &&
|
|
|
|
( cd submod && git clean -f && git reset --hard ) &&
|
|
|
|
git submodule update -N
|
|
|
|
'
|
|
|
|
|
2008-02-22 07:31:56 +08:00
|
|
|
test_done
|