Merge branch 'rebase-p-first-parent' into devel
[git/mingw/j6t.git] / t / t3032-merge-recursive-options.sh
blobf716767636d2054fee7e7a3c1189393d6f9c5950
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 if test_have_prereq GREP_STRIPS_CR
18 then
19 GREP_OPTIONS=-U
20 export GREP_OPTIONS
23 test_expect_success 'setup' '
24 conflict_hunks () {
25 sed $SED_OPTIONS -n -e "
26 /^<<<</ b conflict
28 : conflict
30 /^>>>>/ b
32 b conflict
33 " "$@"
34 } &&
36 cat <<-\EOF >text.txt &&
37 Hope, he says, cherishes the soul of him who lives in
38 justice and holiness and is the nurse of his age and the
39 companion of his journey;--hope which is mightiest to sway
40 the restless soul of man.
42 How admirable are his words! And the great blessing of riches, I do
43 not say to every man, but to a good man, is, that he has had no
44 occasion to deceive or to defraud others, either intentionally or
45 unintentionally; and when he departs to the world below he is not in
46 any apprehension about offerings due to the gods or debts which he owes
47 to men. Now to this peace of mind the possession of wealth greatly
48 contributes; and therefore I say, that, setting one thing against
49 another, of the many advantages which wealth has to give, to a man of
50 sense this is in my opinion the greatest.
52 Well said, Cephalus, I replied; but as concerning justice, what is
53 it?--to speak the truth and to pay your debts--no more than this? And
54 even to this are there not exceptions? Suppose that a friend when in
55 his right mind has deposited arms with me and he asks for them when he
56 is not in his right mind, ought I to give them back to him? No one
57 would say that I ought or that I should be right in doing so, any more
58 than they would say that I ought always to speak the truth to one who
59 is in his condition.
61 You are quite right, he replied.
63 But then, I said, speaking the truth and paying your debts is not a
64 correct definition of justice.
66 CEPHALUS - SOCRATES - POLEMARCHUS
68 Quite correct, Socrates, if Simonides is to be believed, said
69 Polemarchus interposing.
71 I fear, said Cephalus, that I must go now, for I have to look after the
72 sacrifices, and I hand over the argument to Polemarchus and the company.
73 EOF
74 git add text.txt &&
75 test_tick &&
76 git commit -m "Initial revision" &&
78 git checkout -b remote &&
79 sed -e "
80 s/\. /\. /g
81 s/[?] /? /g
82 s/ / /g
83 s/--/---/g
84 s/but as concerning/but as con cerning/
85 /CEPHALUS - SOCRATES - POLEMARCHUS/ d
86 " text.txt >text.txt+ &&
87 mv text.txt+ text.txt &&
88 git commit -a -m "Remove cruft" &&
90 git checkout master &&
91 sed -e "
92 s/\(not in his right mind\),\(.*\)/\1;\2Q/
93 s/Quite correct\(.*\)/It is too correct\1Q/
94 s/unintentionally/un intentionally/
95 /un intentionally/ s/$/Q/
96 s/Polemarchus interposing./Polemarchus, interposing.Q/
97 /justice and holiness/ s/$/Q/
98 /pay your debts/ s/$/Q/
99 " text.txt | q_to_cr >text.txt+ &&
100 mv text.txt+ text.txt &&
101 git commit -a -m "Clarify" &&
102 git show-branch --all
105 test_expect_success 'naive merge fails' '
106 git read-tree --reset -u HEAD &&
107 test_must_fail git merge-recursive HEAD^ -- HEAD remote &&
108 test_must_fail git update-index --refresh &&
109 grep "<<<<<<" text.txt
112 test_expect_success '--ignore-space-change makes merge succeed' '
113 git read-tree --reset -u HEAD &&
114 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote
117 test_expect_success 'naive cherry-pick fails' '
118 git read-tree --reset -u HEAD &&
119 test_must_fail git cherry-pick --no-commit remote &&
120 git read-tree --reset -u HEAD &&
121 test_must_fail git cherry-pick remote &&
122 test_must_fail git update-index --refresh &&
123 grep "<<<<<<" text.txt
126 test_expect_success '-Xignore-space-change makes cherry-pick succeed' '
127 git read-tree --reset -u HEAD &&
128 git cherry-pick --no-commit -Xignore-space-change remote
131 test_expect_success '--ignore-space-change: our w/s-only change wins' '
132 cat <<-\EOF >expected &&
133 justice and holiness and is the nurse of his age and theQ
136 git read-tree --reset -u HEAD &&
137 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
138 cr_to_q <text.txt > text.txt+ &&
139 grep "justice and holiness" text.txt+ >actual &&
140 test_cmp expected actual
143 test_expect_success '--ignore-space-change: their real change wins over w/s' '
144 cat <<-\EOF >expected &&
145 it?---to speak the truth and to pay your debts---no more than this? And
148 git read-tree --reset -u HEAD &&
149 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
150 grep "pay your debts" text.txt >actual &&
151 test_cmp expected actual
154 test_expect_success '--ignore-space-change: does not ignore new spaces' '
155 cat <<-\EOF >expected1 &&
156 Well said, Cephalus, I replied; but as con cerning justice, what is
158 cat <<-\EOF >expected2 &&
159 un intentionally; and when he departs to the world below he is not inQ
162 git read-tree --reset -u HEAD &&
163 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
164 cr_to_q <text.txt >text.txt+ &&
165 grep "Well said" text.txt+ >actual1 &&
166 grep "when he departs" text.txt+ >actual2 &&
167 test_cmp expected1 actual1 &&
168 test_cmp expected2 actual2
171 test_expect_success '--ignore-all-space drops their new spaces' '
172 cat <<-\EOF >expected &&
173 Well said, Cephalus, I replied; but as concerning justice, what is
176 git read-tree --reset -u HEAD &&
177 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
178 grep "Well said" text.txt >actual &&
179 test_cmp expected actual
182 test_expect_success '--ignore-all-space keeps our new spaces' '
183 cat <<-\EOF >expected &&
184 un intentionally; and when he departs to the world below he is not inQ
187 git read-tree --reset -u HEAD &&
188 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
189 cr_to_q <text.txt >text.txt+ &&
190 grep "when he departs" text.txt+ >actual &&
191 test_cmp expected actual
194 test_expect_success '--ignore-space-at-eol' '
195 cat <<-\EOF >expected &&
196 <<<<<<< HEAD
197 is not in his right mind; ought I to give them back to him? No oneQ
198 =======
199 is not in his right mind, ought I to give them back to him? No one
200 >>>>>>> remote
203 git read-tree --reset -u HEAD &&
204 test_must_fail git merge-recursive --ignore-space-at-eol \
205 HEAD^ -- HEAD remote &&
206 cr_to_q <text.txt >text.txt+ &&
207 conflict_hunks text.txt+ >actual &&
208 test_cmp expected actual
211 test_done