-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·283 lines (249 loc) · 11.1 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/bash
# FIXME use some tmp dir
# FIXME write tests that hit all types of conflicts
rm -rf scrap
mkdir -p scrap/remote
mkdir scrap/local
cd scrap/remote
git init --initial-branch=master >/dev/null || exit 1
touch one.txt
touch two.txt
touch three.txt
git add --all || exit 1
git commit -m 'initial commit' >/dev/null || exit 1
git switch --create feature >/dev/null 2>&1 || exit 1
echo two > two.txt
git commit --all --message two >/dev/null || exit 1
echo three > three.txt
git commit --all --message three >/dev/null || exit 1
git switch master >/dev/null 2>&1 || exit 1
cd ..
git clone remote local >/dev/null 2>&1 || exit 1
cd local
git switch --create feature >/dev/null 2>&1 || exit 1
git branch --set-upstream-to origin/feature >/dev/null || exit 1
git reset --hard origin/feature >/dev/null || exit 1
echo "mit merge"
echo "========="
echo " | branch | merge | working tree |"
echo " | -------------------------------------- |"
echo " | ahead | none | clean |"
git reset --hard origin/feature >/dev/null || exit 1
echo four >> three.txt
git commit --all --message "four" >/dev/null || exit 1
head0=$(git rev-parse feature)
mit merge feature >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
mit undo >/dev/null && exit 1
echo " | ahead | none | dirty |"
git reset --hard origin/feature >/dev/null || exit 1
echo four >> three.txt
git commit --all --message "four" >/dev/null || exit 1
echo five >> three.txt
head0=$(git rev-parse feature)
mit merge feature >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
mit undo >/dev/null && exit 1
echo " | diverged | bubble | clean |"
git reset --hard origin/feature^ >/dev/null || exit 1
echo three >> two.txt
git commit --all --message "three" >/dev/null || exit 1
head0=$(git rev-parse feature)
mit merge feature >/dev/null || exit 1
[ $(git rev-parse feature^) = $head0 ] || exit 1
[ $(git rev-parse feature^2) = $(git rev-parse origin/feature) ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
echo " | diverged | bubble | dirty |"
git reset --hard origin/feature^ >/dev/null || exit 1
echo three >> two.txt
git commit --all --message "three" >/dev/null || exit 1
echo four >> two.txt
head0=$(git rev-parse feature)
mit merge feature >/dev/null || exit 1
[ $(git rev-parse feature^) = $head0 ] || exit 1
[ $(git rev-parse feature^2) = $(git rev-parse origin/feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
echo " | diverged | bubble | conflicting |"
git reset --hard origin/feature^ >/dev/null || exit 1
echo three >> two.txt
git commit --all --message "three" >/dev/null || exit 1
echo four >> three.txt
head0=$(git rev-parse feature)
mit merge feature >/dev/null || exit 1
[ $(git rev-parse feature^) = $head0 ] || exit 1
[ $(git rev-parse feature^2) = $(git rev-parse origin/feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 5 insertions(+)" ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
echo " | diverged | conflicting | clean |"
git reset --hard origin/feature^ >/dev/null || exit 1
echo four >> three.txt
git commit --all --message "four" >/dev/null || exit 1
head0=$(git rev-parse feature)
mit merge feature >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 5 insertions(+)" ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
echo " | diverged | conflicting | dirty |"
git reset --hard origin/feature^ >/dev/null || exit 1
echo four >> three.txt
git commit --all --message "four" >/dev/null || exit 1
echo three >> two.txt
head0=$(git rev-parse feature)
mit merge feature >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 5 insertions(+)" ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = $head0 ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
echo " | diverged | conflicting | conflicting |"
echo "mit sync: local = remote, no changes"
git reset --hard origin/feature >/dev/null || exit 1
mit sync >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
mit undo >/dev/null && exit
echo "mit sync: local = remote, changes"
echo three >> three.txt
mit sync >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
mit undo >/dev/null && exit 1
echo "mit sync: local behind remote, no changes"
git reset --hard origin/feature^ >/dev/null || exit 1
mit sync >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature^) ] || exit 1
echo "mit sync: local behind remote, changes (conflicts)"
git reset --hard origin/feature^ >/dev/null || exit 1
echo two >> two.txt
mit sync >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = "$(git rev-parse origin/feature^)" ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
echo "mit sync: local behind remote, changes (no conflicts)"
git reset --hard origin/feature^ >/dev/null || exit 1
echo four > three.txt
mit sync >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 5 insertions(+)" ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature^) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
echo "mit sync: local ahead of remote, no changes"
git reset --hard origin/feature >/dev/null || exit 1
head=$(git rev-parse HEAD)
echo two >> two.txt
git commit --all --message two >/dev/null || exit 1
mit sync >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
mit undo >/dev/null && exit 1
git reset --hard HEAD^ >/dev/null || exit 1
git push --force >/dev/null 2>&1 || exit 1
echo "mit sync: local ahead of remote, changes"
git reset --hard origin/feature >/dev/null || exit 1
head=$(git rev-parse HEAD)
echo two >> two.txt
git commit --all --message two >/dev/null || exit 1
echo three >> two.txt
mit sync >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
mit undo >/dev/null && exit 1
git reset --hard HEAD^ >/dev/null || exit 1
git push --force >/dev/null 2>&1 || exit 1
echo "TODO mit sync: local diverged from remote (no conflicts), no changes"
echo "TODO mit sync: local diverged from remote (no conflicts), changes (no conflicts)"
echo "TODO mit sync: local diverged from remote (no conflicts), changes (conflicts)"
echo "TODO mit sync: local diverged from remote (conflicts), no changes"
echo "TODO mit sync: local diverged from remote (conflicts), changes (no conflicts)"
echo "TODO mit sync: local diverged from remote (conflicts), changes (conflicts)"
echo "mit commit: local = remote"
git reset --hard origin/feature >/dev/null || exit 1
head=$(git rev-parse HEAD)
echo three >> three.txt
MIT_COMMIT_MESSAGE=three mit commit </dev/null >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
[ $head = $(git rev-parse feature^) ] || exit 1
mit undo >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
[ $head = $(git rev-parse feature^^) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
git reset --hard HEAD^^ >/dev/null || exit 1
git push --force >/dev/null 2>&1 || exit 1
echo "mit commit: local = remote, commit aborted"
git reset --hard origin/feature >/dev/null || exit 1
echo three >> three.txt
mit commit </dev/null >/dev/null || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
mit undo >/dev/null && exit 1
echo "mit commit: local behind remote"
git reset --hard origin/feature^ >/dev/null || exit 1
local0=$(git rev-parse feature)
remote0=$(git rev-parse origin/feature)
echo two >> two.txt
MIT_COMMIT_MESSAGE=two mit commit </dev/null >/dev/null && exit 1
MIT_COMMIT_MESSAGE=two mit commit </dev/null >/dev/null || exit 1
[ $local0 = $(git rev-parse feature^) ] || exit 1
[ $remote0 = $(git rev-parse origin/feature) ] || exit 1
mit undo >/dev/null || exit 1
[ $local0 = $(git rev-parse feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
set +x
echo "mit commit: local ahead of remote"
git reset --hard origin/feature >/dev/null || exit 1
head=$(git rev-parse HEAD)
git push origin --force HEAD^:feature >/dev/null 2>&1 || exit 1
echo three >> three.txt
MIT_COMMIT_MESSAGE=three mit commit </dev/null >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
[ $head = $(git rev-parse feature^) ]
mit undo >/dev/null && exit 1
git reset --hard $head >/dev/null || exit 1
git push --force >/dev/null 2>&1 || exit 1
echo "mit commit: local ahead of remote, commit aborted"
git reset --hard origin/feature >/dev/null || exit 1
head=$(git rev-parse HEAD)
git push origin --force HEAD^:feature >/dev/null 2>&1 || exit 1
echo three >> three.txt
mit commit </dev/null >/dev/null || exit 1
[ $(git rev-parse feature) = $(git rev-parse origin/feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
mit undo >/dev/null && exit 1
git reset --hard $head >/dev/null || exit 1
git push --force >/dev/null 2>&1 || exit 1
echo "mit commit: local diverged from remote"
git reset --hard origin/feature^ >/dev/null || exit 1
upstream0=$(git rev-parse origin/feature)
echo two >> two.txt
git commit --all --message two >/dev/null || exit 1
local0=$(git rev-parse feature)
echo two >> two.txt
MIT_COMMIT_MESSAGE=two mit commit </dev/null >/dev/null || exit 1
[ $upstream0 = $(git rev-parse origin/feature) ] || exit 1
[ $local0 = $(git rev-parse feature^) ] || exit 1
mit undo >/dev/null || exit 1
[ $local0 = $(git rev-parse feature) ] || exit 1
[ "$(git diff --shortstat)" = " 1 file changed, 1 insertion(+)" ] || exit 1
echo "mit commit: local diverged from remote, commit aborted"
git reset --hard origin/feature^ >/dev/null || exit 1
upstream0=$(git rev-parse origin/feature)
echo two >> two.txt
git commit --all --message two >/dev/null || exit 1
local0=$(git rev-parse feature)
echo two >> two.txt
mit commit </dev/null >/dev/null || exit 1
[ $upstream0 = $(git rev-parse origin/feature) ] || exit 1
[ $local0 = $(git rev-parse feature) ] || exit 1
mit undo >/dev/null && exit 1
cd ../..
rm -rf scrap