Fix old-style function declaration
[git/dscho.git] / t / t3032-merge-recursive-options.sh
blob2b17311cb0870ea210d9b5cbe167363d13641d67
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 'naive cherry-pick fails' '
114 git read-tree --reset -u HEAD &&
115 test_must_fail git cherry-pick --no-commit remote &&
116 git read-tree --reset -u HEAD &&
117 test_must_fail git cherry-pick remote &&
118 test_must_fail git update-index --refresh &&
119 grep "<<<<<<" text.txt
122 test_expect_success '-Xignore-space-change makes cherry-pick succeed' '
123 git read-tree --reset -u HEAD &&
124 git cherry-pick --no-commit -Xignore-space-change remote
127 test_expect_success '--ignore-space-change: our w/s-only change wins' '
128 q_to_cr <<-\EOF >expected &&
129 justice and holiness and is the nurse of his age and theQ
132 git read-tree --reset -u HEAD &&
133 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
134 grep "justice and holiness" text.txt >actual &&
135 test_cmp expected actual
138 test_expect_success '--ignore-space-change: their real change wins over w/s' '
139 cat <<-\EOF >expected &&
140 it?---to speak the truth and to pay your debts---no more than this? And
143 git read-tree --reset -u HEAD &&
144 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
145 grep "pay your debts" text.txt >actual &&
146 test_cmp expected actual
149 test_expect_success '--ignore-space-change: does not ignore new spaces' '
150 cat <<-\EOF >expected1 &&
151 Well said, Cephalus, I replied; but as con cerning justice, what is
153 q_to_cr <<-\EOF >expected2 &&
154 un intentionally; and when he departs to the world below he is not inQ
157 git read-tree --reset -u HEAD &&
158 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
159 grep "Well said" text.txt >actual1 &&
160 grep "when he departs" text.txt >actual2 &&
161 test_cmp expected1 actual1 &&
162 test_cmp expected2 actual2
165 test_expect_success '--ignore-all-space drops their new spaces' '
166 cat <<-\EOF >expected &&
167 Well said, Cephalus, I replied; but as concerning justice, what is
170 git read-tree --reset -u HEAD &&
171 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
172 grep "Well said" text.txt >actual &&
173 test_cmp expected actual
176 test_expect_success '--ignore-all-space keeps our new spaces' '
177 q_to_cr <<-\EOF >expected &&
178 un intentionally; and when he departs to the world below he is not inQ
181 git read-tree --reset -u HEAD &&
182 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
183 grep "when he departs" text.txt >actual &&
184 test_cmp expected actual
187 test_expect_success '--ignore-space-at-eol' '
188 q_to_cr <<-\EOF >expected &&
189 <<<<<<< HEAD
190 is not in his right mind; ought I to give them back to him? No oneQ
191 =======
192 is not in his right mind, ought I to give them back to him? No one
193 >>>>>>> remote
196 git read-tree --reset -u HEAD &&
197 test_must_fail git merge-recursive --ignore-space-at-eol \
198 HEAD^ -- HEAD remote &&
199 conflict_hunks text.txt >actual &&
200 test_cmp expected actual
203 test_done