1#!/bin/sh 2 3test_description='merge-recursive options 4 5* [master] Clarify 6 ! [remote] Remove cruft 7-- 8 + [remote] Remove cruft 9* [master] Clarify 10*+ [remote^] Initial revision 11* ok 1: setup 12' 13 14. ./test-lib.sh 15 16test_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b 17 18test_expect_success 'setup'' 19 conflict_hunks () { 20 sed$SED_OPTIONS-n -e " 21 /^<<<</ b inconflict 22 b 23 : inconflict 24 p 25 /^>>>>/ b 26 n 27 b inconflict 28 " "$@" 29 } && 30 31 cat <<-\EOF >text.txt && 32 Hope, he says, cherishes the soul of him who lives in 33 justice and holiness and is the nurse of his age and the 34 companion of his journey;--hope which is mightiest to sway 35 the restless soul of man. 36 37 How admirable are his words! And the great blessing of riches, I do 38 not say to every man, but to a good man, is, that he has had no 39 occasion to deceive or to defraud others, either intentionally or 40 unintentionally; and when he departs to the world below he is not in 41 any apprehension about offerings due to the gods or debts which he owes 42 to men. Now to this peace of mind the possession of wealth greatly 43 contributes; and therefore I say, that, setting one thing against 44 another, of the many advantages which wealth has to give, to a man of 45 sense this is in my opinion the greatest. 46 47 Well said, Cephalus, I replied; but as concerning justice, what is 48 it?--to speak the truth and to pay your debts--no more than this? And 49 even to this are there not exceptions? Suppose that a friend when in 50 his right mind has deposited arms with me and he asks for them when he 51 is not in his right mind, ought I to give them back to him? No one 52 would say that I ought or that I should be right in doing so, any more 53 than they would say that I ought always to speak the truth to one who 54 is in his condition. 55 56 You are quite right, he replied. 57 58 But then, I said, speaking the truth and paying your debts is not a 59 correct definition of justice. 60 61 CEPHALUS - SOCRATES - POLEMARCHUS 62 63 Quite correct, Socrates, if Simonides is to be believed, said 64 Polemarchus interposing. 65 66 I fear, said Cephalus, that I must go now, for I have to look after the 67 sacrifices, and I hand over the argument to Polemarchus and the company. 68 EOF 69 git add text.txt && 70 test_tick && 71 git commit -m "Initial revision" && 72 73 git checkout -b remote && 74 sed -e " 75 s/\. /\. /g 76 s/[?] /? /g 77 s/ / /g 78 s/--/---/g 79 s/but as concerning/but as con cerning/ 80 /CEPHALUS - SOCRATES - POLEMARCHUS/ d 81 " text.txt >text.txt+ && 82 mv text.txt+ text.txt && 83 git commit -a -m "Remove cruft" && 84 85 git checkout master && 86 sed -e " 87 s/\(not in his right mind\),\(.*\)/\1;\2Q/ 88 s/Quite correct\(.*\)/It is too correct\1Q/ 89 s/unintentionally/un intentionally/ 90 /un intentionally/ s/$/Q/ 91 s/Polemarchus interposing./Polemarchus, interposing.Q/ 92 /justice and holiness/ s/$/Q/ 93 /pay your debts/ s/$/Q/ 94 " text.txt | q_to_cr >text.txt+ && 95 mv text.txt+ text.txt && 96 git commit -a -m "Clarify" && 97 git show-branch --all 98' 99 100test_expect_success 'naive merge fails'' 101 git read-tree --reset -u HEAD && 102 test_must_fail git merge-recursive HEAD^ -- HEAD remote && 103 test_must_fail git update-index --refresh && 104 grep "<<<<<<" text.txt 105' 106 107test_expect_success '--ignore-space-change makes merge succeed'' 108 git read-tree --reset -u HEAD && 109 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote 110' 111 112test_expect_success '--ignore-space-change: our w/s-only change wins'' 113 q_to_cr <<-\EOF >expected && 114 justice and holiness and is the nurse of his age and theQ 115 EOF 116 117 git read-tree --reset -u HEAD && 118 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote && 119 grep "justice and holiness" text.txt >actual && 120 test_cmp expected actual 121' 122 123test_expect_success '--ignore-space-change: their real change wins over w/s'' 124 cat <<-\EOF >expected && 125 it?---to speak the truth and to pay your debts---no more than this? And 126 EOF 127 128 git read-tree --reset -u HEAD && 129 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote && 130 grep "pay your debts" text.txt >actual && 131 test_cmp expected actual 132' 133 134test_expect_success '--ignore-space-change: does not ignore new spaces'' 135 cat <<-\EOF >expected1 && 136 Well said, Cephalus, I replied; but as con cerning justice, what is 137 EOF 138 q_to_cr <<-\EOF >expected2 && 139 un intentionally; and when he departs to the world below he is not inQ 140 EOF 141 142 git read-tree --reset -u HEAD && 143 git merge-recursive --ignore-space-change HEAD^ -- HEAD remote && 144 grep "Well said" text.txt >actual1 && 145 grep "when he departs" text.txt >actual2 && 146 test_cmp expected1 actual1 && 147 test_cmp expected2 actual2 148' 149 150test_expect_success '--ignore-all-space drops their new spaces'' 151 cat <<-\EOF >expected && 152 Well said, Cephalus, I replied; but as concerning justice, what is 153 EOF 154 155 git read-tree --reset -u HEAD && 156 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote && 157 grep "Well said" text.txt >actual && 158 test_cmp expected actual 159' 160 161test_expect_success '--ignore-all-space keeps our new spaces'' 162 q_to_cr <<-\EOF >expected && 163 un intentionally; and when he departs to the world below he is not inQ 164 EOF 165 166 git read-tree --reset -u HEAD && 167 git merge-recursive --ignore-all-space HEAD^ -- HEAD remote && 168 grep "when he departs" text.txt >actual && 169 test_cmp expected actual 170' 171 172test_expect_success '--ignore-space-at-eol'' 173 q_to_cr <<-\EOF >expected && 174 <<<<<<< HEAD 175 is not in his right mind; ought I to give them back to him? No oneQ 176 ======= 177 is not in his right mind, ought I to give them back to him? No one 178 >>>>>>> remote 179 EOF 180 181 git read-tree --reset -u HEAD && 182 test_must_fail git merge-recursive --ignore-space-at-eol \ 183 HEAD^ -- HEAD remote && 184 conflict_hunks text.txt >actual && 185 test_cmp expected actual 186' 187 188test_done