2007-04-07 22:17:35 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='merge-recursive backend test'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup 1' '
|
|
|
|
|
|
|
|
echo hello >a &&
|
|
|
|
o0=$(git hash-object a) &&
|
|
|
|
cp a b &&
|
2007-04-19 12:51:06 +08:00
|
|
|
cp a c &&
|
2007-04-07 22:17:35 +08:00
|
|
|
mkdir d &&
|
|
|
|
cp a d/e &&
|
|
|
|
|
|
|
|
test_tick &&
|
2007-04-19 12:51:06 +08:00
|
|
|
git add a b c d/e &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git commit -m initial &&
|
|
|
|
c0=$(git rev-parse --verify HEAD) &&
|
|
|
|
git branch side &&
|
|
|
|
git branch df-1 &&
|
|
|
|
git branch df-2 &&
|
|
|
|
git branch df-3 &&
|
|
|
|
git branch remove &&
|
|
|
|
|
|
|
|
echo hello >>a &&
|
|
|
|
cp a d/e &&
|
|
|
|
o1=$(git hash-object a) &&
|
|
|
|
|
|
|
|
git add a d/e &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "master modifies a and d/e" &&
|
|
|
|
c1=$(git rev-parse --verify HEAD) &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o1 a"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o1 d/e"
|
|
|
|
echo "100644 $o1 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup 2' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -rf [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git checkout side &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o0 a"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o0 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual &&
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
echo goodbye >>a &&
|
|
|
|
o2=$(git hash-object a) &&
|
|
|
|
|
|
|
|
git add a &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "side modifies a" &&
|
|
|
|
c2=$(git rev-parse --verify HEAD) &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o2 a"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o2 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup 3' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -rf [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git checkout df-1 &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o0 a"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o0 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual &&
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
rm -f b && mkdir b && echo df-1 >b/c && git add b/c &&
|
|
|
|
o3=$(git hash-object b/c) &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "df-1 makes b/c" &&
|
|
|
|
c3=$(git rev-parse --verify HEAD) &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o0 a"
|
|
|
|
echo "100644 blob $o3 b/c"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o0 0 a"
|
|
|
|
echo "100644 $o3 0 b/c"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup 4' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -rf [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git checkout df-2 &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o0 a"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o0 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual &&
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
rm -f a && mkdir a && echo df-2 >a/c && git add a/c &&
|
|
|
|
o4=$(git hash-object a/c) &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "df-2 makes a/c" &&
|
|
|
|
c4=$(git rev-parse --verify HEAD) &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o4 a/c"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o4 0 a/c"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup 5' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -rf [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git checkout remove &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o0 a"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o0 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual &&
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
rm -f b &&
|
|
|
|
echo remove-conflict >a &&
|
|
|
|
|
|
|
|
git add a &&
|
|
|
|
git rm b &&
|
|
|
|
o5=$(git hash-object a) &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "remove removes b and modifies a" &&
|
|
|
|
c5=$(git rev-parse --verify HEAD) &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o5 a"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o5 0 a"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup 6' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -rf [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git checkout df-3 &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o0 a"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o0 d/e"
|
|
|
|
echo "100644 $o0 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o0 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual &&
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
rm -fr d && echo df-3 >d && git add d &&
|
|
|
|
o6=$(git hash-object d) &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "df-3 makes d" &&
|
|
|
|
c6=$(git rev-parse --verify HEAD) &&
|
|
|
|
( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 blob $o0 a"
|
|
|
|
echo "100644 blob $o0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 blob $o0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 blob $o6 d"
|
|
|
|
echo "100644 $o0 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o6 0 d"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive simple' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -fr [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git checkout -f "$c2" &&
|
|
|
|
|
2008-09-03 16:59:27 +08:00
|
|
|
git merge-recursive "$c0" -- "$c2" "$c1"
|
2007-04-07 22:17:35 +08:00
|
|
|
status=$?
|
|
|
|
case "$status" in
|
|
|
|
1)
|
|
|
|
: happy
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "why status $status!!!"
|
|
|
|
false
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive result' '
|
|
|
|
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o0 1 a"
|
|
|
|
echo "100644 $o2 2 a"
|
|
|
|
echo "100644 $o1 3 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
merge: fix numerus bugs around "trivial merge" area
The "trivial merge" codepath wants to optimize itself by making an
internal call to the read-tree machinery, but it does not read the index
before doing so, and the codepath is never exercised. Incidentally, this
failure to read the index upfront means that the safety to refuse doing
anything when the index is unmerged does not kick in, either.
These two problem are fixed by using read_cache_unmerged() that does read
the index before checking if it is unmerged at the beginning of
cmd_merge().
The primary logic of the merge, however, assumes that the process never
reads the index in-core, and the call to write_cache_as_tree() it makes
from write_tree_trivial() will always read from the on-disk index that is
prepared the strategy back-ends. This assumption is now broken by the
above fix. To fix this issue, we now call discard_cache() before calling
write_tree_trivial() when it wants to write the on-disk index as a tree.
When multiple strategies are tried, their results are evaluated by reading
the resulting index and inspecting it. The codepath needs to make a call
to read_cache() for each successful strategy, and for that to work, they
need to discard_cache() the one read by the previous round.
Also the "trivial merge" forgot that the current commit is one of the
parents of the resulting commit.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-24 03:56:57 +08:00
|
|
|
test_expect_success 'fail if the index has unresolved entries' '
|
|
|
|
|
|
|
|
rm -fr [abcd] &&
|
|
|
|
git checkout -f "$c1" &&
|
|
|
|
|
|
|
|
test_must_fail git merge "$c5" &&
|
|
|
|
test_must_fail git merge "$c5" 2> out &&
|
Be more user-friendly when refusing to do something because of conflict.
Various commands refuse to run in the presence of conflicts (commit,
merge, pull, cherry-pick/revert). They all used to provide rough, and
inconsistant error messages.
A new variable advice.resolveconflict is introduced, and allows more
verbose messages, pointing the user to the appropriate solution.
For commit, the error message used to look like this:
$ git commit
foo.txt: needs merge
foo.txt: unmerged (c34a92682e0394bc0d6f4d4a67a8e2d32395c169)
foo.txt: unmerged (3afcd75de8de0bb5076942fcb17446be50451030)
foo.txt: unmerged (c9785d77b76dfe4fb038bf927ee518f6ae45ede4)
error: Error building trees
The "need merge" line is given by refresh_cache. We add the IN_PORCELAIN
option to make the output more consistant with the other porcelain
commands, and catch the error in return, to stop with a clean error
message. The next lines were displayed by a call to cache_tree_update(),
which is not reached anymore if we noticed the conflict.
The new output looks like:
U foo.txt
fatal: 'commit' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.
Pull is slightly modified to abort immediately if $GIT_DIR/MERGE_HEAD
exists instead of waiting for merge to complain.
The behavior of merge and the test-case are slightly modified to reflect
the usual flow: start with conflicts, fix them, and afterwards get rid of
MERGE_HEAD, with different error messages at each stage.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-12 17:54:44 +08:00
|
|
|
grep "not possible because you have unmerged files" out &&
|
|
|
|
git add -u &&
|
|
|
|
test_must_fail git merge "$c5" 2> out &&
|
2009-06-01 17:20:56 +08:00
|
|
|
grep "You have not concluded your merge" out &&
|
|
|
|
rm -f .git/MERGE_HEAD &&
|
|
|
|
test_must_fail git merge "$c5" 2> out &&
|
Be more user-friendly when refusing to do something because of conflict.
Various commands refuse to run in the presence of conflicts (commit,
merge, pull, cherry-pick/revert). They all used to provide rough, and
inconsistant error messages.
A new variable advice.resolveconflict is introduced, and allows more
verbose messages, pointing the user to the appropriate solution.
For commit, the error message used to look like this:
$ git commit
foo.txt: needs merge
foo.txt: unmerged (c34a92682e0394bc0d6f4d4a67a8e2d32395c169)
foo.txt: unmerged (3afcd75de8de0bb5076942fcb17446be50451030)
foo.txt: unmerged (c9785d77b76dfe4fb038bf927ee518f6ae45ede4)
error: Error building trees
The "need merge" line is given by refresh_cache. We add the IN_PORCELAIN
option to make the output more consistant with the other porcelain
commands, and catch the error in return, to stop with a clean error
message. The next lines were displayed by a call to cache_tree_update(),
which is not reached anymore if we noticed the conflict.
The new output looks like:
U foo.txt
fatal: 'commit' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.
Pull is slightly modified to abort immediately if $GIT_DIR/MERGE_HEAD
exists instead of waiting for merge to complain.
The behavior of merge and the test-case are slightly modified to reflect
the usual flow: start with conflicts, fix them, and afterwards get rid of
MERGE_HEAD, with different error messages at each stage.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-12 17:54:44 +08:00
|
|
|
grep "Your local changes to .* would be overwritten by merge." out
|
merge: fix numerus bugs around "trivial merge" area
The "trivial merge" codepath wants to optimize itself by making an
internal call to the read-tree machinery, but it does not read the index
before doing so, and the codepath is never exercised. Incidentally, this
failure to read the index upfront means that the safety to refuse doing
anything when the index is unmerged does not kick in, either.
These two problem are fixed by using read_cache_unmerged() that does read
the index before checking if it is unmerged at the beginning of
cmd_merge().
The primary logic of the merge, however, assumes that the process never
reads the index in-core, and the call to write_cache_as_tree() it makes
from write_tree_trivial() will always read from the on-disk index that is
prepared the strategy back-ends. This assumption is now broken by the
above fix. To fix this issue, we now call discard_cache() before calling
write_tree_trivial() when it wants to write the on-disk index as a tree.
When multiple strategies are tried, their results are evaluated by reading
the resulting index and inspecting it. The codepath needs to make a call
to read_cache() for each successful strategy, and for that to work, they
need to discard_cache() the one read by the previous round.
Also the "trivial merge" forgot that the current commit is one of the
parents of the resulting commit.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-24 03:56:57 +08:00
|
|
|
'
|
|
|
|
|
2007-04-07 22:17:35 +08:00
|
|
|
test_expect_success 'merge-recursive remove conflict' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -fr [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git checkout -f "$c1" &&
|
|
|
|
|
2008-09-03 16:59:27 +08:00
|
|
|
git merge-recursive "$c0" -- "$c1" "$c5"
|
2007-04-07 22:17:35 +08:00
|
|
|
status=$?
|
|
|
|
case "$status" in
|
|
|
|
1)
|
|
|
|
: happy
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "why status $status!!!"
|
|
|
|
false
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive remove conflict' '
|
|
|
|
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o0 1 a"
|
|
|
|
echo "100644 $o1 2 a"
|
|
|
|
echo "100644 $o5 3 a"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f simple' '
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -fr [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout -f "$c1" &&
|
|
|
|
|
2008-09-03 16:59:27 +08:00
|
|
|
git merge-recursive "$c0" -- "$c1" "$c3"
|
2007-04-07 22:17:35 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive result' '
|
|
|
|
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o1 0 a"
|
|
|
|
echo "100644 $o3 0 b/c"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f conflict' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -fr [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout -f "$c1" &&
|
|
|
|
|
2008-09-03 16:59:27 +08:00
|
|
|
git merge-recursive "$c0" -- "$c1" "$c4"
|
2007-04-07 22:17:35 +08:00
|
|
|
status=$?
|
|
|
|
case "$status" in
|
|
|
|
1)
|
|
|
|
: happy
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "why status $status!!!"
|
|
|
|
false
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f conflict result' '
|
|
|
|
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o0 1 a"
|
|
|
|
echo "100644 $o1 2 a"
|
|
|
|
echo "100644 $o4 0 a/c"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f conflict the other way' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -fr [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout -f "$c4" &&
|
|
|
|
|
2008-09-03 16:59:27 +08:00
|
|
|
git merge-recursive "$c0" -- "$c4" "$c1"
|
2007-04-07 22:17:35 +08:00
|
|
|
status=$?
|
|
|
|
case "$status" in
|
|
|
|
1)
|
|
|
|
: happy
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "why status $status!!!"
|
|
|
|
false
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f conflict result the other way' '
|
|
|
|
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o0 1 a"
|
|
|
|
echo "100644 $o1 3 a"
|
|
|
|
echo "100644 $o4 0 a/c"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f conflict' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -fr [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout -f "$c1" &&
|
|
|
|
|
2008-09-03 16:59:27 +08:00
|
|
|
git merge-recursive "$c0" -- "$c1" "$c6"
|
2007-04-07 22:17:35 +08:00
|
|
|
status=$?
|
|
|
|
case "$status" in
|
|
|
|
1)
|
|
|
|
: happy
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "why status $status!!!"
|
|
|
|
false
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f conflict result' '
|
|
|
|
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o1 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o6 3 d"
|
|
|
|
echo "100644 $o0 1 d/e"
|
|
|
|
echo "100644 $o1 2 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f conflict' '
|
|
|
|
|
2007-04-19 12:51:06 +08:00
|
|
|
rm -fr [abcd] &&
|
2007-04-07 22:17:35 +08:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout -f "$c6" &&
|
|
|
|
|
2008-09-03 16:59:27 +08:00
|
|
|
git merge-recursive "$c0" -- "$c6" "$c1"
|
2007-04-07 22:17:35 +08:00
|
|
|
status=$?
|
|
|
|
case "$status" in
|
|
|
|
1)
|
|
|
|
: happy
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "why status $status!!!"
|
|
|
|
false
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge-recursive d/f conflict result' '
|
|
|
|
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o1 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o6 2 d"
|
|
|
|
echo "100644 $o0 1 d/e"
|
|
|
|
echo "100644 $o1 3 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset and 3-way merge' '
|
|
|
|
|
|
|
|
git reset --hard "$c2" &&
|
|
|
|
git read-tree -m "$c0" "$c2" "$c1"
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset and bind merge' '
|
|
|
|
|
|
|
|
git reset --hard master &&
|
|
|
|
git read-tree --prefix=M/ master &&
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o1 0 M/a"
|
|
|
|
echo "100644 $o0 0 M/b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 M/c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 M/d/e"
|
|
|
|
echo "100644 $o1 0 a"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual &&
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
git read-tree --prefix=a1/ master &&
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o1 0 M/a"
|
|
|
|
echo "100644 $o0 0 M/b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 M/c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 M/d/e"
|
|
|
|
echo "100644 $o1 0 a"
|
|
|
|
echo "100644 $o1 0 a1/a"
|
|
|
|
echo "100644 $o0 0 a1/b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 a1/c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 a1/d/e"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
git read-tree --prefix=z/ master &&
|
|
|
|
git ls-files -s >actual &&
|
|
|
|
(
|
|
|
|
echo "100644 $o1 0 M/a"
|
|
|
|
echo "100644 $o0 0 M/b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 M/c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 M/d/e"
|
|
|
|
echo "100644 $o1 0 a"
|
|
|
|
echo "100644 $o1 0 a1/a"
|
|
|
|
echo "100644 $o0 0 a1/b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 a1/c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 a1/d/e"
|
|
|
|
echo "100644 $o0 0 b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 d/e"
|
|
|
|
echo "100644 $o1 0 z/a"
|
|
|
|
echo "100644 $o0 0 z/b"
|
2007-04-19 12:51:06 +08:00
|
|
|
echo "100644 $o0 0 z/c"
|
2007-04-07 22:17:35 +08:00
|
|
|
echo "100644 $o1 0 z/d/e"
|
|
|
|
) >expected &&
|
2008-05-24 13:28:56 +08:00
|
|
|
test_cmp expected actual
|
2007-04-07 22:17:35 +08:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-09-26 04:12:45 +08:00
|
|
|
test_expect_success 'merge removes empty directories' '
|
|
|
|
|
|
|
|
git reset --hard master &&
|
|
|
|
git checkout -b rm &&
|
|
|
|
git rm d/e &&
|
|
|
|
git commit -mremoved-d/e &&
|
|
|
|
git checkout master &&
|
|
|
|
git merge -s recursive rm &&
|
|
|
|
test_must_fail test -d d
|
|
|
|
'
|
|
|
|
|
2007-04-07 22:17:35 +08:00
|
|
|
test_done
|