@matheusbsbs / matheus-bagliano / commits / 86ce6e0dd1
Fork 0

t3310: extract common notes_merge_files_gone()

We have many statements which are duplicated. Extract and replace these duplicate statements with notes_merge_files_gone(). While we're at it, replace the test_might_fail(), which should only be used on git commands. Also, remove the redirection from stderr to /dev/null. This is because the test scripts automatically suppress output already. Otherwise, if a developer asks for verbose output via the `-v` flag, the stderr output may be useful for debugging. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Jan 6, 2020 at 23:53 UTC 86ce6e0dd195d0b0494b0866c4b2771141a3c06c
1 file changed +10 -12
t/t3310-notes-merge-manual-resolve.sh
+10 -12
@@ -32,6 +32,12 @@ verify_notes () {
32 test_cmp "expect_log_$notes_ref" "output_log_$notes_ref"
33 }
34
35 +notes_merge_files_gone () {
36 + # No .git/NOTES_MERGE_* files left
37 + { ls .git/NOTES_MERGE_* >output || :; } &&
38 + test_must_be_empty output
39 +}
40 +
41 cat <<EOF | sort >expect_notes_x
42 6e8e3febca3c2bb896704335cc4d0c34cb2f8715 $commit_sha4
43 e5388c10860456ee60673025345fe2e153eb8cf8 $commit_sha3
@@ -335,9 +341,7 @@ EOF
341 y and z notes on 4th commit
342 EOF
343 git notes merge --commit &&
338 - # No .git/NOTES_MERGE_* files left
339 - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
340 - test_must_be_empty output &&
344 + notes_merge_files_gone &&
345 # Merge commit has pre-merge y and pre-merge z as parents
346 test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&
347 test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&
@@ -397,9 +401,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol
401
402 test_expect_success 'abort notes merge' '
403 git notes merge --abort &&
400 - # No .git/NOTES_MERGE_* files left
401 - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
402 - test_must_be_empty output &&
404 + notes_merge_files_gone &&
405 # m has not moved (still == y)
406 test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" &&
407 # Verify that other notes refs has not changed (w, x, y and z)
@@ -464,9 +466,7 @@ EOF
466 echo "new note on 5th commit" > .git/NOTES_MERGE_WORKTREE/$commit_sha5 &&
467 # Finalize merge
468 git notes merge --commit &&
467 - # No .git/NOTES_MERGE_* files left
468 - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
469 - test_must_be_empty output &&
469 + notes_merge_files_gone &&
470 # Merge commit has pre-merge y and pre-merge z as parents
471 test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&
472 test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&
@@ -553,9 +553,7 @@ EOF
553
554 test_expect_success 'resolve situation by aborting the notes merge' '
555 git notes merge --abort &&
556 - # No .git/NOTES_MERGE_* files left
557 - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
558 - test_must_be_empty output &&
556 + notes_merge_files_gone &&
557 # m has not moved (still == w)
558 test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&
559 # Verify that other notes refs has not changed (w, x, y and z)