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
7 TEST_PASSES_SANITIZE_LEAK
=true
10 test_expect_success setup
'
11 test_write_lines 1 2 3 4 5 6 7 8 9 >file &&
14 git commit -m initial &&
16 sed -e "s/1/one/" -e "s/9/nine/" >file <elif &&
17 git commit -a -m ours &&
19 git checkout -b side HEAD^ &&
21 sed -e "s/9/nueve/" >file <elif &&
22 git commit -a -m theirs &&
27 test_expect_success
'plain recursive - should conflict' '
28 git reset --hard main &&
29 test_must_fail git merge -s recursive side &&
37 test_expect_success
'recursive favouring theirs' '
38 git reset --hard main &&
39 git merge -s recursive -Xtheirs side &&
47 test_expect_success
'recursive favouring ours' '
48 git reset --hard main &&
49 git merge -s recursive -X ours side &&
57 test_expect_success
'binary file with -Xours/-Xtheirs' '
58 echo file binary >.gitattributes &&
60 git reset --hard main &&
61 git merge -s recursive -X theirs side &&
62 git diff --exit-code side HEAD -- file &&
64 git reset --hard main &&
65 git merge -s recursive -X ours side &&
66 git diff --exit-code main HEAD -- file
69 test_expect_success
'pull passes -X to underlying merge' '
70 git reset --hard main && git pull --no-rebase -s recursive -Xours . side &&
71 git reset --hard main && git pull --no-rebase -s recursive -X ours . side &&
72 git reset --hard main && git pull --no-rebase -s recursive -Xtheirs . side &&
73 git reset --hard main && git pull --no-rebase -s recursive -X theirs . side &&
74 git reset --hard main && test_must_fail git pull --no-rebase -s recursive -X bork . side
77 test_expect_success SYMLINKS
'symlink with -Xours/-Xtheirs' '
78 git reset --hard main &&
79 git checkout -b two main &&
80 ln -s target-zero link &&
82 git commit -m "add link pointing to zero" &&
84 ln -f -s target-two link &&
85 git commit -m "add link pointing to two" link &&
87 git checkout -b one HEAD^ &&
88 ln -f -s target-one link &&
89 git commit -m "add link pointing to one" link &&
91 # we expect symbolic links not to resolve automatically, of course
93 test_must_fail git merge -s recursive two &&
95 # favor theirs to resolve to target-two?
98 git merge -s recursive -X theirs two &&
99 git diff --exit-code two HEAD link &&
101 # favor ours to resolve to target-one?
103 git checkout one^0 &&
104 git merge -s recursive -X ours two &&
105 git diff --exit-code one HEAD link