trace: add high resolution timer function to debug performance issues
[git/raj.git] / t / t3032-merge-recursive-options.sh
blob4029c9c8c06d24887e7d9fa7c97c2c8c5826eb42
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 q_to_cr <<-\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 grep "justice and holiness" text.txt >actual &&
139 test_cmp expected actual
142 test_expect_success '--ignore-space-change: their real change wins over w/s' '
143 cat <<-\EOF >expected &&
144 it?---to speak the truth and to pay your debts---no more than this? And
147 git read-tree --reset -u HEAD &&
148 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
149 grep "pay your debts" text.txt >actual &&
150 test_cmp expected actual
153 test_expect_success '--ignore-space-change: does not ignore new spaces' '
154 cat <<-\EOF >expected1 &&
155 Well said, Cephalus, I replied; but as con cerning justice, what is
157 q_to_cr <<-\EOF >expected2 &&
158 un intentionally; and when he departs to the world below he is not inQ
161 git read-tree --reset -u HEAD &&
162 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote &&
163 grep "Well said" text.txt >actual1 &&
164 grep "when he departs" text.txt >actual2 &&
165 test_cmp expected1 actual1 &&
166 test_cmp expected2 actual2
169 test_expect_success '--ignore-all-space drops their new spaces' '
170 cat <<-\EOF >expected &&
171 Well said, Cephalus, I replied; but as concerning justice, what is
174 git read-tree --reset -u HEAD &&
175 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
176 grep "Well said" text.txt >actual &&
177 test_cmp expected actual
180 test_expect_success '--ignore-all-space keeps our new spaces' '
181 q_to_cr <<-\EOF >expected &&
182 un intentionally; and when he departs to the world below he is not inQ
185 git read-tree --reset -u HEAD &&
186 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote &&
187 grep "when he departs" text.txt >actual &&
188 test_cmp expected actual
191 test_expect_success '--ignore-space-at-eol' '
192 q_to_cr <<-\EOF >expected &&
193 <<<<<<< HEAD
194 is not in his right mind; ought I to give them back to him? No oneQ
195 =======
196 is not in his right mind, ought I to give them back to him? No one
197 >>>>>>> remote
200 git read-tree --reset -u HEAD &&
201 test_must_fail git merge-recursive --ignore-space-at-eol \
202 HEAD^ -- HEAD remote &&
203 conflict_hunks text.txt >actual &&
204 test_cmp expected actual
207 test_done