]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t1410-reflog.sh: avoid suppressing git's exit code in pipelines
authorGatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>
Thu, 9 Jul 2026 05:09:35 +0000 (10:39 +0530)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Jul 2026 16:36:19 +0000 (09:36 -0700)
Piping git commands directly to wc -l suppresses the exit code of
git, hiding potential failures from the test suite. Use
test_stdout_line_count instead, which handles exit code preservation
internally while keeping the test logic clean and readable.

Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1410-reflog.sh

index ce71f9a30ae1ee54f678c6e99bbd0a82fd4041bc..5a40a62ba25f3a33e4e840492ab3536d05c43160 100755 (executable)
@@ -244,30 +244,22 @@ test_expect_success 'delete' '
        test_tick &&
        git commit -m tiger C &&
 
-       HEAD_entry_count=$(git reflog | wc -l) &&
-       main_entry_count=$(git reflog show main | wc -l) &&
-
-       test $HEAD_entry_count = 5 &&
-       test $main_entry_count = 5 &&
-
+       test_stdout_line_count = 5 git reflog &&
+       test_stdout_line_count = 5 git reflog show main &&
 
        git reflog delete main@{1} &&
+       test_stdout_line_count = 4 git reflog show main &&
+       test_stdout_line_count = 5 git reflog &&
        git reflog show main > output &&
-       test_line_count = $(($main_entry_count - 1)) output &&
-       test $HEAD_entry_count = $(git reflog | wc -l) &&
        ! grep ox < output &&
 
-       main_entry_count=$(wc -l < output) &&
-
        git reflog delete HEAD@{1} &&
-       test $(($HEAD_entry_count -1)) = $(git reflog | wc -l) &&
-       test $main_entry_count = $(git reflog show main | wc -l) &&
-
-       HEAD_entry_count=$(git reflog | wc -l) &&
+       test_stdout_line_count = 4 git reflog &&
+       test_stdout_line_count = 4 git reflog show main &&
 
        git reflog delete main@{07.04.2005.15:15:00.-0700} &&
+       test_stdout_line_count = 3 git reflog show main &&
        git reflog show main > output &&
-       test_line_count = $(($main_entry_count - 1)) output &&
        ! grep dragon < output
 
 '
@@ -321,11 +313,11 @@ test_expect_success 'git reflog expire unknown reference' '
 '
 
 test_expect_success 'checkout should not delete log for packed ref' '
-       test $(git reflog main | wc -l) = 4 &&
+       test_stdout_line_count = 4 git reflog main &&
        git branch foo &&
        git pack-refs --all &&
        git checkout foo &&
-       test $(git reflog main | wc -l) = 4
+       test_stdout_line_count = 4 git reflog main
 '
 
 test_expect_success 'stale dirs do not cause d/f conflicts (reflogs on)' '