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
17 TEST_PASSES_SANITIZE_LEAK
=true
20 test_have_prereq SED_STRIPS_CR
&& SED_OPTIONS
=-b
21 if test_have_prereq GREP_STRIPS_CR
27 test_expect_success
'setup' '
29 sed $SED_OPTIONS -n -e "
40 cat <<-\EOF >text.txt &&
41 Hope, he says, cherishes the soul of him who lives in
42 justice and holiness and is the nurse of his age and the
43 companion of his journey;--hope which is mightiest to sway
44 the restless soul of man.
46 How admirable are his words! And the great blessing of riches, I do
47 not say to every man, but to a good man, is, that he has had no
48 occasion to deceive or to defraud others, either intentionally or
49 unintentionally; and when he departs to the world below he is not in
50 any apprehension about offerings due to the gods or debts which he owes
51 to men. Now to this peace of mind the possession of wealth greatly
52 contributes; and therefore I say, that, setting one thing against
53 another, of the many advantages which wealth has to give, to a man of
54 sense this is in my opinion the greatest.
56 Well said, Cephalus, I replied; but as concerning justice, what is
57 it?--to speak the truth and to pay your debts--no more than this? And
58 even to this are there not exceptions? Suppose that a friend when in
59 his right mind has deposited arms with me and he asks for them when he
60 is not in his right mind, ought I to give them back to him? No one
61 would say that I ought or that I should be right in doing so, any more
62 than they would say that I ought always to speak the truth to one who
65 You are quite right, he replied.
67 But then, I said, speaking the truth and paying your debts is not a
68 correct definition of justice.
70 CEPHALUS - SOCRATES - POLEMARCHUS
72 Quite correct, Socrates, if Simonides is to be believed, said
73 Polemarchus interposing.
75 I fear, said Cephalus, that I must go now, for I have to look after the
76 sacrifices, and I hand over the argument to Polemarchus and the company.
80 git commit -m "Initial revision" &&
82 git checkout -b remote &&
88 s/but as concerning/but as con cerning/
89 /CEPHALUS - SOCRATES - POLEMARCHUS/ d
90 " text.txt >text.txt+ &&
91 mv text.txt+ text.txt &&
92 git commit -a -m "Remove cruft" &&
96 s/\(not in his right mind\),\(.*\)/\1;\2Q/
97 s/Quite correct\(.*\)/It is too correct\1Q/
98 s/unintentionally/un intentionally/
99 /un intentionally/ s/$/Q/
100 s/Polemarchus interposing./Polemarchus, interposing.Q/
101 /justice and holiness/ s/$/Q/
102 /pay your debts/ s/$/Q/
103 " text.txt | q_to_cr >text.txt+ &&
104 mv text.txt+ text.txt &&
105 git commit -a -m "Clarify" &&
106 git show-branch --all
109 test_expect_success
'naive merge fails' '
110 git read-tree --reset -u HEAD &&
111 test_must_fail git merge-recursive HEAD^ -- HEAD remote &&
112 test_must_fail git update-index --refresh &&
113 grep "<<<<<<" text.txt
116 test_expect_success
'--ignore-space-change makes merge succeed' '
117 git read-tree --reset -u HEAD &&
118 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote
121 test_expect_success
'naive cherry-pick fails' '
122 git read-tree --reset -u HEAD &&
123 test_must_fail git cherry-pick --no-commit remote &&
124 git read-tree --reset -u HEAD &&
125 test_must_fail git cherry-pick remote &&
126 test_must_fail git update-index --refresh &&
127 grep "<<<<<<" text.txt
130 test_expect_success
'-Xignore-space-change makes cherry-pick succeed' '
131 git read-tree --reset -u HEAD &&
132 git cherry-pick --no-commit -Xignore-space-change remote
135 test_expect_success
'--ignore-space-change: our w/s-only change wins' '
136 q_to_cr <<-\EOF >expected &&
137 justice and holiness and is the nurse of his age and theQ
140 git read-tree --reset -u HEAD &&
141 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
142 grep "justice and holiness" text.txt >actual &&
143 test_cmp expected actual
146 test_expect_success
'--ignore-space-change: their real change wins over w/s' '
147 cat <<-\EOF >expected &&
148 it?---to speak the truth and to pay your debts---no more than this? And
151 git read-tree --reset -u HEAD &&
152 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
153 grep "pay your debts" text.txt >actual &&
154 test_cmp expected actual
157 test_expect_success
'--ignore-space-change: does not ignore new spaces' '
158 cat <<-\EOF >expected1 &&
159 Well said, Cephalus, I replied; but as con cerning justice, what is
161 q_to_cr <<-\EOF >expected2 &&
162 un intentionally; and when he departs to the world below he is not inQ
165 git read-tree --reset -u HEAD &&
166 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
167 grep "Well said" text.txt >actual1 &&
168 grep "when he departs" text.txt >actual2 &&
169 test_cmp expected1 actual1 &&
170 test_cmp expected2 actual2
173 test_expect_success
'--ignore-all-space drops their new spaces' '
174 cat <<-\EOF >expected &&
175 Well said, Cephalus, I replied; but as concerning justice, what is
178 git read-tree --reset -u HEAD &&
179 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
180 grep "Well said" text.txt >actual &&
181 test_cmp expected actual
184 test_expect_success
'--ignore-all-space keeps our new spaces' '
185 q_to_cr <<-\EOF >expected &&
186 un intentionally; and when he departs to the world below he is not inQ
189 git read-tree --reset -u HEAD &&
190 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
191 grep "when he departs" text.txt >actual &&
192 test_cmp expected actual
195 test_expect_success
'--ignore-space-at-eol' '
196 q_to_cr <<-\EOF >expected &&
198 is not in his right mind; ought I to give them back to him? No oneQ
200 is not in his right mind, ought I to give them back to him? No one
204 git read-tree --reset -u HEAD &&
205 test_must_fail git merge-recursive --ignore-space-at-eol \
206 HEAD^ -- HEAD remote &&
207 conflict_hunks text.txt >actual &&
208 test_cmp expected actual