filter-branch: Test renaming directories in a tree-filter
[git/platforms.git] / t / t6023-merge-file.sh
blob79dc58b2ce962ea133c4796d0dff66eb9684b48a
1 #!/bin/sh
3 test_description='RCS merge replacement: merge-file'
4 . ./test-lib.sh
6 cat > orig.txt << EOF
7 Dominus regit me,
8 et nihil mihi deerit.
9 In loco pascuae ibi me collocavit,
10 super aquam refectionis educavit me;
11 animam meam convertit,
12 deduxit me super semitas jusitiae,
13 propter nomen suum.
14 EOF
16 cat > new1.txt << EOF
17 Dominus regit me,
18 et nihil mihi deerit.
19 In loco pascuae ibi me collocavit,
20 super aquam refectionis educavit me;
21 animam meam convertit,
22 deduxit me super semitas jusitiae,
23 propter nomen suum.
24 Nam et si ambulavero in medio umbrae mortis,
25 non timebo mala, quoniam tu mecum es:
26 virga tua et baculus tuus ipsa me consolata sunt.
27 EOF
29 cat > new2.txt << EOF
30 Dominus regit me, et nihil mihi deerit.
31 In loco pascuae ibi me collocavit,
32 super aquam refectionis educavit me;
33 animam meam convertit,
34 deduxit me super semitas jusitiae,
35 propter nomen suum.
36 EOF
38 cat > new3.txt << EOF
39 DOMINUS regit me,
40 et nihil mihi deerit.
41 In loco pascuae ibi me collocavit,
42 super aquam refectionis educavit me;
43 animam meam convertit,
44 deduxit me super semitas jusitiae,
45 propter nomen suum.
46 EOF
48 cat > new4.txt << EOF
49 Dominus regit me, et nihil mihi deerit.
50 In loco pascuae ibi me collocavit,
51 super aquam refectionis educavit me;
52 animam meam convertit,
53 deduxit me super semitas jusitiae,
54 EOF
55 printf "propter nomen suum." >> new4.txt
57 cp new1.txt test.txt
58 test_expect_success "merge without conflict" \
59 "git merge-file test.txt orig.txt new2.txt"
61 cp new1.txt test2.txt
62 test_expect_success "merge without conflict (missing LF at EOF)" \
63 "git merge-file test2.txt orig.txt new2.txt"
65 test_expect_success "merge result added missing LF" \
66 "git diff test.txt test2.txt"
68 cp test.txt backup.txt
69 test_expect_success "merge with conflicts" \
70 "! git merge-file test.txt orig.txt new3.txt"
72 cat > expect.txt << EOF
73 <<<<<<< test.txt
74 Dominus regit me, et nihil mihi deerit.
75 =======
76 DOMINUS regit me,
77 et nihil mihi deerit.
78 >>>>>>> new3.txt
79 In loco pascuae ibi me collocavit,
80 super aquam refectionis educavit me;
81 animam meam convertit,
82 deduxit me super semitas jusitiae,
83 propter nomen suum.
84 Nam et si ambulavero in medio umbrae mortis,
85 non timebo mala, quoniam tu mecum es:
86 virga tua et baculus tuus ipsa me consolata sunt.
87 EOF
89 test_expect_success "expected conflict markers" "git diff test.txt expect.txt"
91 cp backup.txt test.txt
92 test_expect_success "merge with conflicts, using -L" \
93 "! git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
95 cat > expect.txt << EOF
96 <<<<<<< 1
97 Dominus regit me, et nihil mihi deerit.
98 =======
99 DOMINUS regit me,
100 et nihil mihi deerit.
101 >>>>>>> new3.txt
102 In loco pascuae ibi me collocavit,
103 super aquam refectionis educavit me;
104 animam meam convertit,
105 deduxit me super semitas jusitiae,
106 propter nomen suum.
107 Nam et si ambulavero in medio umbrae mortis,
108 non timebo mala, quoniam tu mecum es:
109 virga tua et baculus tuus ipsa me consolata sunt.
112 test_expect_success "expected conflict markers, with -L" \
113 "git diff test.txt expect.txt"
115 sed "s/ tu / TU /" < new1.txt > new5.txt
116 test_expect_success "conflict in removed tail" \
117 "! git merge-file -p orig.txt new1.txt new5.txt > out"
119 cat > expect << EOF
120 Dominus regit me,
121 et nihil mihi deerit.
122 In loco pascuae ibi me collocavit,
123 super aquam refectionis educavit me;
124 animam meam convertit,
125 deduxit me super semitas jusitiae,
126 propter nomen suum.
127 <<<<<<< orig.txt
128 =======
129 Nam et si ambulavero in medio umbrae mortis,
130 non timebo mala, quoniam TU mecum es:
131 virga tua et baculus tuus ipsa me consolata sunt.
132 >>>>>>> new5.txt
135 test_expect_success "expected conflict markers" "git diff expect out"
137 test_expect_success 'binary files cannot be merged' '
138 ! git merge-file -p orig.txt ../test4012.png new1.txt 2> merge.err &&
139 grep "Cannot merge binary files" merge.err
142 sed -e "s/deerit.$/deerit;/" -e "s/me;$/me./" < new5.txt > new6.txt
143 sed -e "s/deerit.$/deerit,/" -e "s/me;$/me,/" < new5.txt > new7.txt
145 test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' '
147 ! git merge-file -p new6.txt new5.txt new7.txt > output &&
148 test 1 = $(grep ======= < output | wc -l)
152 sed -e 's/deerit./&\n\n\n\n/' -e "s/locavit,/locavit;/" < new6.txt > new8.txt
153 sed -e 's/deerit./&\n\n\n\n/' -e "s/locavit,/locavit --/" < new7.txt > new9.txt
155 test_expect_success 'ZEALOUS_ALNUM' '
157 ! git merge-file -p new8.txt new5.txt new9.txt > merge.out &&
158 test 1 = $(grep ======= < merge.out | wc -l)
162 test_done