@matheusbsbs / matheus-bagliano / commits / dd0f1e767b
Fork 0

t5520: use test_cmp_rev where possible

In case an invocation of `git rev-list` fails within the command substitution, the failure will be masked. Remove the command substitution and use test_cmp_rev() so that failures can be discovered. This change was done with the following sed expressions: s/test "$(git rev-parse.* \([^)]*\))" = "$(git rev-parse \([^)]*\))"/test_cmp_rev \1 \2/ s/test \([^ ]*\) = "$(git rev-parse.* \([^)]*\))"/test_cmp_rev \1 \2/ s/test "$(git rev-parse.* \([^)]*\))" != "$(git rev-parse.* \([^)]*\))"/test_cmp_rev ! \1 \2/ s/test \([^ ]*\) != "$(git rev-parse.* \([^)]*\))"/test_cmp_rev ! \1 \2/ Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Nov 12, 2019 at 15:08 UTC dd0f1e767b79009f5edd01d3c917f1cf186e60c9
1 file changed +25 -25
t/t5520-pull.sh
+25 -25
@@ -230,7 +230,7 @@ test_expect_success 'fast-forwards working tree if branch head is updated' '
230 git pull . second:third 2>err &&
231 test_i18ngrep "fetch updated the current branch head" err &&
232 test "$(cat file)" = modified &&
233 - test "$(git rev-parse third)" = "$(git rev-parse second)"
233 + test_cmp_rev third second
234 '
235
236 test_expect_success 'fast-forward fails with conflicting work tree' '
@@ -241,7 +241,7 @@ test_expect_success 'fast-forward fails with conflicting work tree' '
241 test_must_fail git pull . second:third 2>err &&
242 test_i18ngrep "Cannot fast-forward your working tree" err &&
243 test "$(cat file)" = conflict &&
244 - test "$(git rev-parse third)" = "$(git rev-parse second)"
244 + test_cmp_rev third second
245 '
246
247 test_expect_success '--rebase' '
@@ -254,7 +254,7 @@ test_expect_success '--rebase' '
254 git commit -m "new file" &&
255 git tag before-rebase &&
256 git pull --rebase . copy &&
257 - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
257 + test_cmp_rev HEAD^ copy &&
258 test new = "$(git show HEAD:file2)"
259 '
260
@@ -266,7 +266,7 @@ test_expect_success '--rebase fast forward' '
266
267 git checkout to-rebase &&
268 git pull --rebase . ff &&
269 - test "$(git rev-parse HEAD)" = "$(git rev-parse ff)" &&
269 + test_cmp_rev HEAD ff &&
270
271 # The above only validates the result. Did we actually bypass rebase?
272 git reflog -1 >reflog.actual &&
@@ -290,7 +290,7 @@ test_expect_success '--rebase --autostash fast forward' '
290 git checkout behind &&
291 echo dirty >file &&
292 git pull --rebase --autostash . to-rebase-ff &&
293 - test "$(git rev-parse HEAD)" = "$(git rev-parse to-rebase-ff)"
293 + test_cmp_rev HEAD to-rebase-ff
294 '
295
296 test_expect_success '--rebase with conflicts shows advice' '
@@ -328,7 +328,7 @@ test_expect_success 'failed --rebase shows advice' '
328 test_expect_success '--rebase fails with multiple branches' '
329 git reset --hard before-rebase &&
330 test_must_fail git pull --rebase . copy master 2>err &&
331 - test "$(git rev-parse HEAD)" = "$(git rev-parse before-rebase)" &&
331 + test_cmp_rev HEAD before-rebase &&
332 test_i18ngrep "Cannot rebase onto multiple branches" err &&
333 test modified = "$(git show HEAD:file)"
334 '
@@ -380,7 +380,7 @@ test_expect_success 'pull.rebase' '
380 git reset --hard before-rebase &&
381 test_config pull.rebase true &&
382 git pull . copy &&
383 - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
383 + test_cmp_rev HEAD^ copy &&
384 test new = "$(git show HEAD:file2)"
385 '
386
@@ -398,7 +398,7 @@ test_expect_success 'branch.to-rebase.rebase' '
398 git reset --hard before-rebase &&
399 test_config branch.to-rebase.rebase true &&
400 git pull . copy &&
401 - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
401 + test_cmp_rev HEAD^ copy &&
402 test new = "$(git show HEAD:file2)"
403 '
404
@@ -407,14 +407,14 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
407 test_config pull.rebase true &&
408 test_config branch.to-rebase.rebase false &&
409 git pull . copy &&
410 - test "$(git rev-parse HEAD^)" != "$(git rev-parse copy)" &&
410 + test_cmp_rev ! HEAD^ copy &&
411 test new = "$(git show HEAD:file2)"
412 '
413
414 test_expect_success 'pull --rebase warns on --verify-signatures' '
415 git reset --hard before-rebase &&
416 git pull --rebase --verify-signatures . copy 2>err &&
417 - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
417 + test_cmp_rev HEAD^ copy &&
418 test new = "$(git show HEAD:file2)" &&
419 test_i18ngrep "ignoring --verify-signatures for rebase" err
420 '
@@ -422,7 +422,7 @@ test_expect_success 'pull --rebase warns on --verify-signatures' '
422 test_expect_success 'pull --rebase does not warn on --no-verify-signatures' '
423 git reset --hard before-rebase &&
424 git pull --rebase --no-verify-signatures . copy 2>err &&
425 - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
425 + test_cmp_rev HEAD^ copy &&
426 test new = "$(git show HEAD:file2)" &&
427 test_i18ngrep ! "verify-signatures" err
428 '
@@ -443,8 +443,8 @@ test_expect_success 'pull.rebase=false create a new merge commit' '
443 git reset --hard before-preserve-rebase &&
444 test_config pull.rebase false &&
445 git pull . copy &&
446 - test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" &&
447 - test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" &&
446 + test_cmp_rev HEAD^1 before-preserve-rebase &&
447 + test_cmp_rev HEAD^2 copy &&
448 test file3 = "$(git show HEAD:file3.t)"
449 '
450
@@ -452,7 +452,7 @@ test_expect_success 'pull.rebase=true flattens keep-merge' '
452 git reset --hard before-preserve-rebase &&
453 test_config pull.rebase true &&
454 git pull . copy &&
455 - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
455 + test_cmp_rev HEAD^^ copy &&
456 test file3 = "$(git show HEAD:file3.t)"
457 '
458
@@ -460,7 +460,7 @@ test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' '
460 git reset --hard before-preserve-rebase &&
461 test_config pull.rebase 1 &&
462 git pull . copy &&
463 - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
463 + test_cmp_rev HEAD^^ copy &&
464 test file3 = "$(git show HEAD:file3.t)"
465 '
466
@@ -469,8 +469,8 @@ test_expect_success REBASE_P \
469 git reset --hard before-preserve-rebase &&
470 test_config pull.rebase preserve &&
471 git pull . copy &&
472 - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
473 - test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
472 + test_cmp_rev HEAD^^ copy &&
473 + test_cmp_rev HEAD^2 keep-merge
474 '
475
476 test_expect_success 'pull.rebase=interactive' '
@@ -505,8 +505,8 @@ test_expect_success '--rebase=false create a new merge commit' '
505 git reset --hard before-preserve-rebase &&
506 test_config pull.rebase true &&
507 git pull --rebase=false . copy &&
508 - test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" &&
509 - test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" &&
508 + test_cmp_rev HEAD^1 before-preserve-rebase &&
509 + test_cmp_rev HEAD^2 copy &&
510 test file3 = "$(git show HEAD:file3.t)"
511 '
512
@@ -514,7 +514,7 @@ test_expect_success '--rebase=true rebases and flattens keep-merge' '
514 git reset --hard before-preserve-rebase &&
515 test_config pull.rebase preserve &&
516 git pull --rebase=true . copy &&
517 - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
517 + test_cmp_rev HEAD^^ copy &&
518 test file3 = "$(git show HEAD:file3.t)"
519 '
520
@@ -523,8 +523,8 @@ test_expect_success REBASE_P \
523 git reset --hard before-preserve-rebase &&
524 test_config pull.rebase true &&
525 git pull --rebase=preserve . copy &&
526 - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
527 - test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
526 + test_cmp_rev HEAD^^ copy &&
527 + test_cmp_rev HEAD^2 keep-merge
528 '
529
530 test_expect_success '--rebase=invalid fails' '
@@ -536,7 +536,7 @@ test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-m
536 git reset --hard before-preserve-rebase &&
537 test_config pull.rebase preserve &&
538 git pull --rebase . copy &&
539 - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
539 + test_cmp_rev HEAD^^ copy &&
540 test file3 = "$(git show HEAD:file3.t)"
541 '
542
@@ -597,10 +597,10 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
597 echo dirty >>file &&
598 git add file &&
599 test_must_fail git pull &&
600 - test "$COPY" = "$(git rev-parse --verify me/copy)" &&
600 + test_cmp_rev "$COPY" me/copy &&
601 git checkout HEAD -- file &&
602 git pull &&
603 - test "$COPY" != "$(git rev-parse --verify me/copy)"
603 + test_cmp_rev ! "$COPY" me/copy
604 '
605
606 test_expect_success 'pull --rebase works on branch yet to be born' '