Always use oidread to read into struct object_id
[git/gitster.git] / t / t6417-merge-ours-theirs.sh
blobac9aee9a6625530f385b038f59776073044e691f
1 #!/bin/sh
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-lib.sh
9 test_expect_success setup '
10 for i in 1 2 3 4 5 6 7 8 9
12 echo "$i"
13 done >file &&
14 git add file &&
15 cp file elif &&
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 &&
26 git checkout main^0
29 test_expect_success 'plain recursive - should conflict' '
30 git reset --hard main &&
31 test_must_fail git merge -s recursive side &&
32 grep nine file &&
33 grep nueve file &&
34 ! grep 9 file &&
35 grep one file &&
36 ! grep 1 file
39 test_expect_success 'recursive favouring theirs' '
40 git reset --hard main &&
41 git merge -s recursive -Xtheirs side &&
42 ! grep nine file &&
43 grep nueve file &&
44 ! grep 9 file &&
45 grep one file &&
46 ! grep 1 file
49 test_expect_success 'recursive favouring ours' '
50 git reset --hard main &&
51 git merge -s recursive -X ours side &&
52 grep nine file &&
53 ! grep nueve file &&
54 ! grep 9 file &&
55 grep one file &&
56 ! grep 1 file
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 &&
83 git add 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
94 git checkout one^0 &&
95 test_must_fail git merge -s recursive two &&
97 # favor theirs to resolve to target-two?
98 git reset --hard &&
99 git checkout one^0 &&
100 git merge -s recursive -X theirs two &&
101 git diff --exit-code two HEAD link &&
103 # favor ours to resolve to target-one?
104 git reset --hard &&
105 git checkout one^0 &&
106 git merge -s recursive -X ours two &&
107 git diff --exit-code one HEAD link
111 test_done