Skip to content

Commit 9f6cea9

Browse files
Benabikgitster
authored andcommitted
t6022: Use -eq not = to test output of wc -l
When comparing numbers such as "3" to "$(wc -l)", we should check for numerical equality using -eq instead of string equality using = because some implementations of wc output extra whitespace. Signed-off-by: Brian Gernhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c851650 commit 9f6cea9

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

t/t6022-merge-rename.sh

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' '
404404
grep "Auto-merging dir" output &&
405405
grep "Adding as dir~HEAD instead" output &&
406406
407-
test 2 = "$(git ls-files -u | wc -l)" &&
408-
test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
407+
test 2 -eq "$(git ls-files -u | wc -l)" &&
408+
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
409409
410410
test_must_fail git diff --quiet &&
411411
test_must_fail git diff --cached --quiet &&
@@ -426,8 +426,8 @@ test_expect_success 'Same as previous, but merged other way' '
426426
grep "Auto-merging dir" output &&
427427
grep "Adding as dir~renamed-file-has-no-conflicts instead" output &&
428428
429-
test 2 = "$(git ls-files -u | wc -l)" &&
430-
test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
429+
test 2 -eq "$(git ls-files -u | wc -l)" &&
430+
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
431431
432432
test_must_fail git diff --quiet &&
433433
test_must_fail git diff --cached --quiet &&
@@ -461,8 +461,8 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in
461461
git checkout -q renamed-file-has-conflicts^0 &&
462462
test_must_fail git merge --strategy=recursive dir-not-in-way &&
463463
464-
test 3 = "$(git ls-files -u | wc -l)" &&
465-
test 3 = "$(git ls-files -u dir | wc -l)" &&
464+
test 3 -eq "$(git ls-files -u | wc -l)" &&
465+
test 3 -eq "$(git ls-files -u dir | wc -l)" &&
466466
467467
test_must_fail git diff --quiet &&
468468
test_must_fail git diff --cached --quiet &&
@@ -479,9 +479,9 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in t
479479
git checkout -q renamed-file-has-conflicts^0 &&
480480
test_must_fail git merge --strategy=recursive dir-in-way &&
481481
482-
test 5 = "$(git ls-files -u | wc -l)" &&
483-
test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
484-
test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
482+
test 5 -eq "$(git ls-files -u | wc -l)" &&
483+
test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
484+
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
485485
486486
test_must_fail git diff --quiet &&
487487
test_must_fail git diff --cached --quiet &&
@@ -515,9 +515,9 @@ test_expect_success 'Same as previous, but merged other way' '
515515
git checkout -q dir-in-way^0 &&
516516
test_must_fail git merge --strategy=recursive renamed-file-has-conflicts &&
517517
518-
test 5 = "$(git ls-files -u | wc -l)" &&
519-
test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
520-
test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
518+
test 5 -eq "$(git ls-files -u | wc -l)" &&
519+
test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
520+
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
521521
522522
test_must_fail git diff --quiet &&
523523
test_must_fail git diff --cached --quiet &&
@@ -555,7 +555,7 @@ test_expect_success 'both rename source and destination involved in D/F conflict
555555
git checkout -q rename-dest^0 &&
556556
test_must_fail git merge --strategy=recursive source-conflict &&
557557
558-
test 1 = "$(git ls-files -u | wc -l)" &&
558+
test 1 -eq "$(git ls-files -u | wc -l)" &&
559559
560560
test_must_fail git diff --quiet &&
561561
@@ -594,13 +594,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked
594594
mkdir one &&
595595
test_must_fail git merge --strategy=recursive rename-two &&
596596
597-
test 2 = "$(git ls-files -u | wc -l)" &&
598-
test 1 = "$(git ls-files -u one | wc -l)" &&
599-
test 1 = "$(git ls-files -u two | wc -l)" &&
597+
test 2 -eq "$(git ls-files -u | wc -l)" &&
598+
test 1 -eq "$(git ls-files -u one | wc -l)" &&
599+
test 1 -eq "$(git ls-files -u two | wc -l)" &&
600600
601601
test_must_fail git diff --quiet &&
602602
603-
test 4 = $(find . | grep -v .git | wc -l) &&
603+
test 4 -eq $(find . | grep -v .git | wc -l) &&
604604
605605
test -d one &&
606606
test -f one~rename-two &&
@@ -614,13 +614,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta
614614
git clean -fdqx &&
615615
test_must_fail git merge --strategy=recursive rename-two &&
616616
617-
test 2 = "$(git ls-files -u | wc -l)" &&
618-
test 1 = "$(git ls-files -u one | wc -l)" &&
619-
test 1 = "$(git ls-files -u two | wc -l)" &&
617+
test 2 -eq "$(git ls-files -u | wc -l)" &&
618+
test 1 -eq "$(git ls-files -u one | wc -l)" &&
619+
test 1 -eq "$(git ls-files -u two | wc -l)" &&
620620
621621
test_must_fail git diff --quiet &&
622622
623-
test 3 = $(find . | grep -v .git | wc -l) &&
623+
test 3 -eq $(find . | grep -v .git | wc -l) &&
624624
625625
test -f one &&
626626
test -f two &&
@@ -656,12 +656,12 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
656656
git checkout -q first-rename^0 &&
657657
test_must_fail git merge --strategy=recursive second-rename &&
658658
659-
test 5 = "$(git ls-files -s | wc -l)" &&
660-
test 3 = "$(git ls-files -u | wc -l)" &&
661-
test 1 = "$(git ls-files -u one | wc -l)" &&
662-
test 1 = "$(git ls-files -u two | wc -l)" &&
663-
test 1 = "$(git ls-files -u original | wc -l)" &&
664-
test 2 = "$(git ls-files -o | wc -l)" &&
659+
test 5 -eq "$(git ls-files -s | wc -l)" &&
660+
test 3 -eq "$(git ls-files -u | wc -l)" &&
661+
test 1 -eq "$(git ls-files -u one | wc -l)" &&
662+
test 1 -eq "$(git ls-files -u two | wc -l)" &&
663+
test 1 -eq "$(git ls-files -u original | wc -l)" &&
664+
test 2 -eq "$(git ls-files -o | wc -l)" &&
665665
666666
test -f one/file &&
667667
test -f two/file &&
@@ -696,11 +696,11 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
696696
git checkout -q first-rename-redo^0 &&
697697
test_must_fail git merge --strategy=recursive second-rename-redo &&
698698
699-
test 3 = "$(git ls-files -u | wc -l)" &&
700-
test 1 = "$(git ls-files -u one | wc -l)" &&
701-
test 1 = "$(git ls-files -u two | wc -l)" &&
702-
test 1 = "$(git ls-files -u original | wc -l)" &&
703-
test 0 = "$(git ls-files -o | wc -l)" &&
699+
test 3 -eq "$(git ls-files -u | wc -l)" &&
700+
test 1 -eq "$(git ls-files -u one | wc -l)" &&
701+
test 1 -eq "$(git ls-files -u two | wc -l)" &&
702+
test 1 -eq "$(git ls-files -u original | wc -l)" &&
703+
test 0 -eq "$(git ls-files -o | wc -l)" &&
704704
705705
test -f one &&
706706
test -f two &&

0 commit comments

Comments
 (0)