t6007: Make sure we test --cherry-pick
[git.git] / t / t3032-merge-recursive-options.sh
blob44f5421be45579b10c5556a958404ad2daa02002
1 #!/bin/sh
3 test_description='merge-recursive options
5 * [master] Clarify
6 ! [remote] Remove cruft
7 --
8 + [remote] Remove cruft
9 * [master] Clarify
10 *+ [remote^] Initial revision
11 * ok 1: setup
14 . ./test-lib.sh
16 test_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b
17 test_have_prereq MINGW && export GREP_OPTIONS=-U
19 test_expect_success 'setup' '
20 conflict_hunks () {
21 sed $SED_OPTIONS -n -e "
22 /^<<<</ b conflict
24 : conflict
26 /^>>>>/ b
28 b conflict
29 " "$@"
30 } &&
32 cat <<-\EOF >text.txt &&
33 Hope, he says, cherishes the soul of him who lives in
34 justice and holiness and is the nurse of his age and the
35 companion of his journey;--hope which is mightiest to sway
36 the restless soul of man.
38 How admirable are his words! And the great blessing of riches, I do
39 not say to every man, but to a good man, is, that he has had no
40 occasion to deceive or to defraud others, either intentionally or
41 unintentionally; and when he departs to the world below he is not in
42 any apprehension about offerings due to the gods or debts which he owes
43 to men. Now to this peace of mind the possession of wealth greatly
44 contributes; and therefore I say, that, setting one thing against
45 another, of the many advantages which wealth has to give, to a man of
46 sense this is in my opinion the greatest.
48 Well said, Cephalus, I replied; but as concerning justice, what is
49 it?--to speak the truth and to pay your debts--no more than this? And
50 even to this are there not exceptions? Suppose that a friend when in
51 his right mind has deposited arms with me and he asks for them when he
52 is not in his right mind, ought I to give them back to him? No one
53 would say that I ought or that I should be right in doing so, any more
54 than they would say that I ought always to speak the truth to one who
55 is in his condition.
57 You are quite right, he replied.
59 But then, I said, speaking the truth and paying your debts is not a
60 correct definition of justice.
62 CEPHALUS - SOCRATES - POLEMARCHUS
64 Quite correct, Socrates, if Simonides is to be believed, said
65 Polemarchus interposing.
67 I fear, said Cephalus, that I must go now, for I have to look after the
68 sacrifices, and I hand over the argument to Polemarchus and the company.
69 EOF
70 git add text.txt &&
71 test_tick &&
72 git commit -m "Initial revision" &&
74 git checkout -b remote &&
75 sed -e "
76 s/\. /\. /g
77 s/[?] /? /g
78 s/ / /g
79 s/--/---/g
80 s/but as concerning/but as con cerning/
81 /CEPHALUS - SOCRATES - POLEMARCHUS/ d
82 " text.txt >text.txt+ &&
83 mv text.txt+ text.txt &&
84 git commit -a -m "Remove cruft" &&
86 git checkout master &&
87 sed -e "
88 s/\(not in his right mind\),\(.*\)/\1;\2Q/
89 s/Quite correct\(.*\)/It is too correct\1Q/
90 s/unintentionally/un intentionally/
91 /un intentionally/ s/$/Q/
92 s/Polemarchus interposing./Polemarchus, interposing.Q/
93 /justice and holiness/ s/$/Q/
94 /pay your debts/ s/$/Q/
95 " text.txt | q_to_cr >text.txt+ &&
96 mv text.txt+ text.txt &&
97 git commit -a -m "Clarify" &&
98 git show-branch --all
101 test_expect_success 'naive merge fails' '
102 git read-tree --reset -u HEAD &&
103 test_must_fail git merge-recursive HEAD^ -- HEAD remote &&
104 test_must_fail git update-index --refresh &&
105 grep "<<<<<<" text.txt
108 test_expect_success '--ignore-space-change makes merge succeed' '
109 git read-tree --reset -u HEAD &&
110 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote
113 test_expect_success '--ignore-space-change: our w/s-only change wins' '
114 q_to_cr <<-\EOF >expected &&
115 justice and holiness and is the nurse of his age and theQ
118 git read-tree --reset -u HEAD &&
119 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
120 grep "justice and holiness" text.txt >actual &&
121 test_cmp expected actual
124 test_expect_success '--ignore-space-change: their real change wins over w/s' '
125 cat <<-\EOF >expected &&
126 it?---to speak the truth and to pay your debts---no more than this? And
129 git read-tree --reset -u HEAD &&
130 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
131 grep "pay your debts" text.txt >actual &&
132 test_cmp expected actual
135 test_expect_success '--ignore-space-change: does not ignore new spaces' '
136 cat <<-\EOF >expected1 &&
137 Well said, Cephalus, I replied; but as con cerning justice, what is
139 q_to_cr <<-\EOF >expected2 &&
140 un intentionally; and when he departs to the world below he is not inQ
143 git read-tree --reset -u HEAD &&
144 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
145 grep "Well said" text.txt >actual1 &&
146 grep "when he departs" text.txt >actual2 &&
147 test_cmp expected1 actual1 &&
148 test_cmp expected2 actual2
151 test_expect_success '--ignore-all-space drops their new spaces' '
152 cat <<-\EOF >expected &&
153 Well said, Cephalus, I replied; but as concerning justice, what is
156 git read-tree --reset -u HEAD &&
157 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
158 grep "Well said" text.txt >actual &&
159 test_cmp expected actual
162 test_expect_success '--ignore-all-space keeps our new spaces' '
163 q_to_cr <<-\EOF >expected &&
164 un intentionally; and when he departs to the world below he is not inQ
167 git read-tree --reset -u HEAD &&
168 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
169 grep "when he departs" text.txt >actual &&
170 test_cmp expected actual
173 test_expect_success '--ignore-space-at-eol' '
174 q_to_cr <<-\EOF >expected &&
175 <<<<<<< HEAD
176 is not in his right mind; ought I to give them back to him? No oneQ
177 =======
178 is not in his right mind, ought I to give them back to him? No one
179 >>>>>>> remote
182 git read-tree --reset -u HEAD &&
183 test_must_fail git merge-recursive --ignore-space-at-eol \
184 HEAD^ -- HEAD remote &&
185 conflict_hunks text.txt >actual &&
186 test_cmp expected actual
189 test_done