3 test_description
='merge-recursive space options
6 ! [remote] Remove cruft
8 + [remote] Remove cruft
10 *+ [remote^] Initial revision
14 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
15 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
19 test_have_prereq SED_STRIPS_CR
&& SED_OPTIONS
=-b
20 if test_have_prereq GREP_STRIPS_CR
26 test_expect_success
'setup' '
28 sed $SED_OPTIONS -n -e "
39 cat <<-\EOF >text.txt &&
40 Hope, he says, cherishes the soul of him who lives in
41 justice and holiness and is the nurse of his age and the
42 companion of his journey;--hope which is mightiest to sway
43 the restless soul of man.
45 How admirable are his words! And the great blessing of riches, I do
46 not say to every man, but to a good man, is, that he has had no
47 occasion to deceive or to defraud others, either intentionally or
48 unintentionally; and when he departs to the world below he is not in
49 any apprehension about offerings due to the gods or debts which he owes
50 to men. Now to this peace of mind the possession of wealth greatly
51 contributes; and therefore I say, that, setting one thing against
52 another, of the many advantages which wealth has to give, to a man of
53 sense this is in my opinion the greatest.
55 Well said, Cephalus, I replied; but as concerning justice, what is
56 it?--to speak the truth and to pay your debts--no more than this? And
57 even to this are there not exceptions? Suppose that a friend when in
58 his right mind has deposited arms with me and he asks for them when he
59 is not in his right mind, ought I to give them back to him? No one
60 would say that I ought or that I should be right in doing so, any more
61 than they would say that I ought always to speak the truth to one who
64 You are quite right, he replied.
66 But then, I said, speaking the truth and paying your debts is not a
67 correct definition of justice.
69 CEPHALUS - SOCRATES - POLEMARCHUS
71 Quite correct, Socrates, if Simonides is to be believed, said
72 Polemarchus interposing.
74 I fear, said Cephalus, that I must go now, for I have to look after the
75 sacrifices, and I hand over the argument to Polemarchus and the company.
79 git commit -m "Initial revision" &&
81 git checkout -b remote &&
87 s/but as concerning/but as con cerning/
88 /CEPHALUS - SOCRATES - POLEMARCHUS/ d
89 " text.txt >text.txt+ &&
90 mv text.txt+ text.txt &&
91 git commit -a -m "Remove cruft" &&
95 s/\(not in his right mind\),\(.*\)/\1;\2Q/
96 s/Quite correct\(.*\)/It is too correct\1Q/
97 s/unintentionally/un intentionally/
98 /un intentionally/ s/$/Q/
99 s/Polemarchus interposing./Polemarchus, interposing.Q/
100 /justice and holiness/ s/$/Q/
101 /pay your debts/ s/$/Q/
102 " text.txt | q_to_cr >text.txt+ &&
103 mv text.txt+ text.txt &&
104 git commit -a -m "Clarify" &&
105 git show-branch --all
108 test_expect_success
'naive merge fails' '
109 git read-tree --reset -u HEAD &&
110 test_must_fail git merge-recursive HEAD^ -- HEAD remote &&
111 test_must_fail git update-index --refresh &&
112 grep "<<<<<<" text.txt
115 test_expect_success
'--ignore-space-change makes merge succeed' '
116 git read-tree --reset -u HEAD &&
117 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote
120 test_expect_success
'naive cherry-pick fails' '
121 git read-tree --reset -u HEAD &&
122 test_must_fail git cherry-pick --no-commit remote &&
123 git read-tree --reset -u HEAD &&
124 test_must_fail git cherry-pick remote &&
125 test_must_fail git update-index --refresh &&
126 grep "<<<<<<" text.txt
129 test_expect_success
'-Xignore-space-change makes cherry-pick succeed' '
130 git read-tree --reset -u HEAD &&
131 git cherry-pick --no-commit -Xignore-space-change remote
134 test_expect_success
'--ignore-space-change: our w/s-only change wins' '
135 q_to_cr <<-\EOF >expected &&
136 justice and holiness and is the nurse of his age and theQ
139 git read-tree --reset -u HEAD &&
140 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
141 grep "justice and holiness" text.txt >actual &&
142 test_cmp expected actual
145 test_expect_success
'--ignore-space-change: their real change wins over w/s' '
146 cat <<-\EOF >expected &&
147 it?---to speak the truth and to pay your debts---no more than this? And
150 git read-tree --reset -u HEAD &&
151 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
152 grep "pay your debts" text.txt >actual &&
153 test_cmp expected actual
156 test_expect_success
'--ignore-space-change: does not ignore new spaces' '
157 cat <<-\EOF >expected1 &&
158 Well said, Cephalus, I replied; but as con cerning justice, what is
160 q_to_cr <<-\EOF >expected2 &&
161 un intentionally; and when he departs to the world below he is not inQ
164 git read-tree --reset -u HEAD &&
165 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
166 grep "Well said" text.txt >actual1 &&
167 grep "when he departs" text.txt >actual2 &&
168 test_cmp expected1 actual1 &&
169 test_cmp expected2 actual2
172 test_expect_success
'--ignore-all-space drops their new spaces' '
173 cat <<-\EOF >expected &&
174 Well said, Cephalus, I replied; but as concerning justice, what is
177 git read-tree --reset -u HEAD &&
178 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
179 grep "Well said" text.txt >actual &&
180 test_cmp expected actual
183 test_expect_success
'--ignore-all-space keeps our new spaces' '
184 q_to_cr <<-\EOF >expected &&
185 un intentionally; and when he departs to the world below he is not inQ
188 git read-tree --reset -u HEAD &&
189 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
190 grep "when he departs" text.txt >actual &&
191 test_cmp expected actual
194 test_expect_success
'--ignore-space-at-eol' '
195 q_to_cr <<-\EOF >expected &&
197 is not in his right mind; ought I to give them back to him? No oneQ
199 is not in his right mind, ought I to give them back to him? No one
203 git read-tree --reset -u HEAD &&
204 test_must_fail git merge-recursive --ignore-space-at-eol \
205 HEAD^ -- HEAD remote &&
206 conflict_hunks text.txt >actual &&
207 test_cmp expected actual