@@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '
98
98
'
99
99
100
100
test_expect_success ' replace the author' '
101
- git cat-file commit $HASH2 | grep "author A U Thor" &&
102
- R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
103
- git cat-file commit $R | grep "author O Thor" &&
101
+ git cat-file commit $HASH2 >actual &&
102
+ test_grep "author A U Thor" actual &&
103
+ R=$(sed -e "s/A U/O/" actual | git hash-object -t commit --stdin -w) &&
104
+ git cat-file commit $R >actual &&
105
+ test_grep "author O Thor" actual &&
104
106
git update-ref refs/replace/$HASH2 $R &&
105
- git show HEAD~5 | grep "O Thor" &&
106
- git show $HASH2 | grep "O Thor"
107
+ git show HEAD~5 >actual &&
108
+ test_grep "O Thor" actual &&
109
+ git show $HASH2 >actual &&
110
+ test_grep "O Thor" actual
107
111
'
108
112
109
113
test_expect_success ' test --no-replace-objects option' '
110
- git cat-file commit $HASH2 | grep "author O Thor" &&
111
- git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" &&
112
- git show $HASH2 | grep "O Thor" &&
113
- git --no-replace-objects show $HASH2 | grep "A U Thor"
114
+ git cat-file commit $HASH2 >actual &&
115
+ test_grep "author O Thor" actual &&
116
+ git --no-replace-objects cat-file commit $HASH2 >actual &&
117
+ test_grep "author A U Thor" actual &&
118
+ git show $HASH2 >actual &&
119
+ test_grep "O Thor" actual &&
120
+ git --no-replace-objects show $HASH2 >actual &&
121
+ test_grep "A U Thor" actual
114
122
'
115
123
116
124
test_expect_success ' test GIT_NO_REPLACE_OBJECTS env variable' '
117
- GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" &&
118
- GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor"
125
+ GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&
126
+ test_grep "author A U Thor" actual &&
127
+ GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&
128
+ test_grep "A U Thor" actual
119
129
'
120
130
121
131
test_expect_success ' test core.usereplacerefs config option' '
122
132
test_config core.usereplacerefs false &&
123
- git cat-file commit $HASH2 | grep "author A U Thor" &&
124
- git show $HASH2 | grep "A U Thor"
133
+ git cat-file commit $HASH2 >actual &&
134
+ test_grep "author A U Thor" actual &&
135
+ git show $HASH2 >actual &&
136
+ test_grep "A U Thor" actual
125
137
'
126
138
127
139
cat > tag.sig << EOF
@@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '
148
160
git clone --no-hardlinks . clone_dir &&
149
161
(
150
162
cd clone_dir &&
151
- git show HEAD~5 | grep "A U Thor" &&
152
- git show $HASH2 | grep "A U Thor" &&
163
+ git show HEAD~5 >actual &&
164
+ test_grep "A U Thor" actual &&
165
+ git show $HASH2 >actual &&
166
+ test_grep "A U Thor" actual &&
153
167
git cat-file commit $R &&
154
168
git repack -a -d &&
155
169
test_must_fail git cat-file commit $R &&
156
170
git fetch ../ "refs/replace/*:refs/replace/*" &&
157
- git show HEAD~5 | grep "O Thor" &&
158
- git show $HASH2 | grep "O Thor" &&
171
+ git show HEAD~5 >actual &&
172
+ test_grep "O Thor" actual &&
173
+ git show $HASH2 >actual &&
174
+ test_grep "O Thor" actual &&
159
175
git cat-file commit $R
160
176
)
161
177
'
@@ -169,13 +185,15 @@ test_expect_success '"git replace" listing and deleting' '
169
185
test_must_fail git replace --delete &&
170
186
test_must_fail git replace -l -d $HASH2 &&
171
187
git replace -d $HASH2 &&
172
- git show $HASH2 | grep "A U Thor" &&
188
+ git show $HASH2 >actual &&
189
+ test_grep "A U Thor" actual &&
173
190
test -z "$(git replace -l)"
174
191
'
175
192
176
193
test_expect_success ' "git replace" replacing' '
177
194
git replace $HASH2 $R &&
178
- git show $HASH2 | grep "O Thor" &&
195
+ git show $HASH2 >actual &&
196
+ test_grep "O Thor" actual &&
179
197
test_must_fail git replace $HASH2 $R &&
180
198
git replace -f $HASH2 $R &&
181
199
test_must_fail git replace -f &&
@@ -186,7 +204,8 @@ test_expect_success '"git replace" resolves sha1' '
186
204
SHORTHASH2=$(git rev-parse --short=8 $HASH2) &&
187
205
git replace -d $SHORTHASH2 &&
188
206
git replace $SHORTHASH2 $R &&
189
- git show $HASH2 | grep "O Thor" &&
207
+ git show $HASH2 >actual &&
208
+ test_grep "O Thor" actual &&
190
209
test_must_fail git replace $HASH2 $R &&
191
210
git replace -f $HASH2 $R &&
192
211
test_must_fail git replace --force &&
@@ -209,10 +228,12 @@ test_expect_success '"git replace" resolves sha1' '
209
228
#
210
229
test_expect_success ' create parallel branch without the bug' '
211
230
git replace -d $HASH2 &&
212
- git show $HASH2 | grep "A U Thor" &&
231
+ git show $HASH2 >actual &&
232
+ test_grep "A U Thor" actual &&
213
233
git checkout $HASH1 &&
214
234
git cherry-pick $HASH2 &&
215
- git show $HASH5 | git apply &&
235
+ git show $HASH5 >actual &&
236
+ git apply actual &&
216
237
git commit --amend -m "hello: 4 more lines WITHOUT the bug" hello &&
217
238
PARA2=$(git rev-parse --verify HEAD) &&
218
239
git cherry-pick $HASH3 &&
@@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '
225
246
git checkout main &&
226
247
cur=$(git rev-parse --verify HEAD) &&
227
248
test "$cur" = "$HASH7" &&
228
- git log --pretty=oneline | grep $PARA2 &&
249
+ git log --pretty=oneline >actual &&
250
+ test_grep $PARA2 actual &&
229
251
git remote add cloned ./clone_dir
230
252
'
231
253
@@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '
234
256
(
235
257
cd clone_dir &&
236
258
git checkout parallel &&
237
- git log --pretty=oneline | grep $PARA2
259
+ git log --pretty=oneline >actual &&
260
+ test_grep $PARA2 actual
238
261
)
239
262
'
240
263
241
264
test_expect_success ' push branch with replacement' '
242
- git cat-file commit $PARA3 | grep "author A U Thor" &&
243
- S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
244
- git cat-file commit $S | grep "author O Thor" &&
265
+ git cat-file commit $PARA3 >actual &&
266
+ test_grep "author A U Thor" actual &&
267
+ S=$(sed -e "s/A U/O/" actual | git hash-object -t commit --stdin -w) &&
268
+ git cat-file commit $S >actual &&
269
+ test_grep "author O Thor" actual &&
245
270
git replace $PARA3 $S &&
246
- git show $HASH6~2 | grep "O Thor" &&
247
- git show $PARA3 | grep "O Thor" &&
271
+ git show $HASH6~2 >actual &&
272
+ test_grep "O Thor" actual &&
273
+ git show $PARA3 >actual &&
274
+ test_grep "O Thor" actual &&
248
275
git push cloned $HASH6^:refs/heads/parallel2 &&
249
276
(
250
277
cd clone_dir &&
251
278
git checkout parallel2 &&
252
- git log --pretty=oneline | grep $PARA3 &&
253
- git show $PARA3 | grep "A U Thor"
279
+ git log --pretty=oneline >actual &&
280
+ test_grep $PARA3 actual &&
281
+ git show $PARA3 >actual &&
282
+ test_grep "A U Thor" actual
254
283
)
255
284
'
256
285
@@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '
260
289
cd clone_dir &&
261
290
git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&
262
291
git log --pretty=oneline parallel3 >output.txt &&
263
- ! grep $PARA3 output.txt &&
292
+ test_grep ! $PARA3 output.txt &&
264
293
git show $PARA3 >para3.txt &&
265
- grep "A U Thor" para3.txt &&
294
+ test_grep "A U Thor" para3.txt &&
266
295
git fetch origin "refs/replace/*:refs/replace/*" &&
267
296
git log --pretty=oneline parallel3 >output.txt &&
268
- grep $PARA3 output.txt &&
297
+ test_grep $PARA3 output.txt &&
269
298
git show $PARA3 >para3.txt &&
270
- grep "O Thor" para3.txt
299
+ test_grep "O Thor" para3.txt
271
300
)
272
301
'
273
302
@@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '
284
313
'
285
314
286
315
test_expect_success ' index-pack and replacements' '
287
- git --no-replace-objects rev-list --objects HEAD |
288
- git --no-replace-objects pack-objects test- &&
316
+ git --no-replace-objects rev-list --objects HEAD >actual &&
317
+ git --no-replace-objects pack-objects test- <actual &&
289
318
git index-pack test-*.pack
290
319
'
291
320
@@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '
319
348
'
320
349
321
350
test_expect_success ' git cat-file --batch works on replace objects' '
322
- git replace | grep $PARA3 &&
351
+ git replace >actual &&
352
+ test_grep $PARA3 actual &&
323
353
echo $PARA3 | git cat-file --batch
324
354
'
325
355
@@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '
344
374
echo "$PARA3 -> $S" &&
345
375
echo "$MYTAG -> $HASH1"
346
376
} | sort >expected &&
347
- git replace -l --format medium | sort >actual &&
377
+ git replace -l --format medium >output &&
378
+ sort output >actual &&
348
379
test_cmp expected actual
349
380
'
350
381
@@ -356,7 +387,8 @@ test_expect_success 'test --format long' '
356
387
echo "$PARA3 (commit) -> $S (commit)" &&
357
388
echo "$MYTAG (tag) -> $HASH1 (commit)"
358
389
} | sort >expected &&
359
- git replace --format=long | sort >actual &&
390
+ git replace --format=long >output &&
391
+ sort output >actual &&
360
392
test_cmp expected actual
361
393
'
362
394
@@ -374,21 +406,27 @@ test_expect_success 'setup fake editors' '
374
406
test_expect_success ' --edit with and without already replaced object' '
375
407
test_must_fail env GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
376
408
GIT_EDITOR=./fakeeditor git replace --force --edit "$PARA3" &&
377
- git replace -l | grep "$PARA3" &&
378
- git cat-file commit "$PARA3" | grep "A fake Thor" &&
409
+ git replace -l >actual &&
410
+ test_grep "$PARA3" actual &&
411
+ git cat-file commit "$PARA3" >actual &&
412
+ test_grep "A fake Thor" actual &&
379
413
git replace -d "$PARA3" &&
380
414
GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
381
- git replace -l | grep "$PARA3" &&
382
- git cat-file commit "$PARA3" | grep "A fake Thor"
415
+ git replace -l >actual &&
416
+ test_grep "$PARA3" actual &&
417
+ git cat-file commit "$PARA3" >actual &&
418
+ test_grep "A fake Thor" actual
383
419
'
384
420
385
421
test_expect_success ' --edit and change nothing or command failed' '
386
422
git replace -d "$PARA3" &&
387
423
test_must_fail env GIT_EDITOR=true git replace --edit "$PARA3" &&
388
424
test_must_fail env GIT_EDITOR="./failingfakeeditor" git replace --edit "$PARA3" &&
389
425
GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
390
- git replace -l | grep "$PARA3" &&
391
- git cat-file commit "$PARA3" | grep "A fake Thor"
426
+ git replace -l >actual &&
427
+ test_grep "$PARA3" actual &&
428
+ git cat-file commit "$PARA3" >actual &&
429
+ test_grep "A fake Thor" actual
392
430
'
393
431
394
432
test_expect_success ' replace ref cleanup' '
@@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '
468
506
git checkout main &&
469
507
git merge -s ours test_tag &&
470
508
HASH10=$(git rev-parse --verify HEAD) &&
471
- git cat-file commit $HASH10 | grep "^mergetag object"
509
+ git cat-file commit $HASH10 >actual &&
510
+ test_grep "^mergetag object" actual
472
511
'
473
512
474
513
test_expect_success GPG ' --graft on a commit with a mergetag' '
0 commit comments