3 test_description='Merge-recursive ours and theirs variants'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 test_expect_success setup '
10 for i in 1 2 3 4 5 6 7 8 9
16 git commit -m initial &&
18 sed -e "s/1/one/" -e "s/9/nine/" >file <elif &&
19 git commit -a -m ours &&
21 git checkout -b side HEAD^ &&
23 sed -e "s/9/nueve/" >file <elif &&
24 git commit -a -m theirs &&
29 test_expect_success 'plain recursive - should conflict' '
30 git reset --hard main &&
31 test_must_fail git merge -s recursive side &&
39 test_expect_success 'recursive favouring theirs' '
40 git reset --hard main &&
41 git merge -s recursive -Xtheirs side &&
49 test_expect_success 'recursive favouring ours' '
50 git reset --hard main &&
51 git merge -s recursive -X ours side &&
59 test_expect_success 'binary file with -Xours/-Xtheirs' '
60 echo file binary >.gitattributes &&
62 git reset --hard main &&
63 git merge -s recursive -X theirs side &&
64 git diff --exit-code side HEAD -- file &&
66 git reset --hard main &&
67 git merge -s recursive -X ours side &&
68 git diff --exit-code main HEAD -- file
71 test_expect_success 'pull passes -X to underlying merge' '
72 git reset --hard main && git pull -s recursive -Xours . side &&
73 git reset --hard main && git pull -s recursive -X ours . side &&
74 git reset --hard main && git pull -s recursive -Xtheirs . side &&
75 git reset --hard main && git pull -s recursive -X theirs . side &&
76 git reset --hard main && test_must_fail git pull -s recursive -X bork . side
79 test_expect_success SYMLINKS 'symlink with -Xours/-Xtheirs' '
80 git reset --hard main &&
81 git checkout -b two main &&
82 ln -s target-zero link &&
84 git commit -m "add link pointing to zero" &&
86 ln -f -s target-two link &&
87 git commit -m "add link pointing to two" link &&
89 git checkout -b one HEAD^ &&
90 ln -f -s target-one link &&
91 git commit -m "add link pointing to one" link &&
93 # we expect symbolic links not to resolve automatically, of course
95 test_must_fail git merge -s recursive two &&
97 # favor theirs to resolve to target-two?
100 git merge -s recursive -X theirs two &&
101 git diff --exit-code two HEAD link &&
103 # favor ours to resolve to target-one?
105 git checkout one^0 &&
106 git merge -s recursive -X ours two &&
107 git diff --exit-code one HEAD link