* [PATCH] t1410-reflog.sh: avoid suppressing git's exit code in pipelines @ 2026-07-06 20:50 Gatla Vishweshwar Reddy 2026-07-07 2:16 ` Junio C Hamano 0 siblings, 1 reply; 8+ messages in thread From: Gatla Vishweshwar Reddy @ 2026-07-06 20:50 UTC (permalink / raw) To: git; +Cc: Gatla Vishweshwar Reddy Piping git commands directly to wc -l suppresses the exit code of git, hiding potential failures from the test suite. Capture the output to a temporary file first, then count the lines separately to preserve the exit code. Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> --- t/t1410-reflog.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index ce71f9a30a..397f94b039 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -244,8 +244,10 @@ 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) && + git reflog >reflog_output && + HEAD_entry_count=$(wc -l <reflog_output) && + git reflog show main >reflog_main_output && + main_entry_count=$(wc -l <reflog_main_output) && test $HEAD_entry_count = 5 && test $main_entry_count = 5 && @@ -254,16 +256,23 @@ test_expect_success 'delete' ' git reflog delete main@{1} && git reflog show main > output && test_line_count = $(($main_entry_count - 1)) output && - test $HEAD_entry_count = $(git reflog | wc -l) && + git reflog >reflog_output && + test $HEAD_entry_count = $(wc -l <reflog_output) && ! 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) && + git reflog >reflog_output && + test $(($HEAD_entry_count -1)) = $(wc -l <reflog_output) && + git reflog show main >reflog_main_output && + test $main_entry_count = $(wc -l <reflog_main_output) && + + + git reflog >reflog_output && + HEAD_entry_count=$(wc -l <reflog_output) && + - HEAD_entry_count=$(git reflog | wc -l) && git reflog delete main@{07.04.2005.15:15:00.-0700} && git reflog show main > output && @@ -321,11 +330,15 @@ 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 && + git reflog main >reflog_output && + test $(wc -l <reflog_output) = 4 && git branch foo && git pack-refs --all && git checkout foo && - test $(git reflog main | wc -l) = 4 + git reflog main >reflog_output && + test $(wc -l <reflog_output) = 4 + + ' test_expect_success 'stale dirs do not cause d/f conflicts (reflogs on)' ' -- 2.54.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] t1410-reflog.sh: avoid suppressing git's exit code in pipelines 2026-07-06 20:50 [PATCH] t1410-reflog.sh: avoid suppressing git's exit code in pipelines Gatla Vishweshwar Reddy @ 2026-07-07 2:16 ` Junio C Hamano 2026-07-07 13:55 ` [PATCH v2] " Gatla Vishweshwar Reddy 2026-07-08 9:20 ` [PATCH v3] " Gatla Vishweshwar Reddy 0 siblings, 2 replies; 8+ messages in thread From: Junio C Hamano @ 2026-07-07 2:16 UTC (permalink / raw) To: Gatla Vishweshwar Reddy; +Cc: git Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes: > Piping git commands directly to wc -l suppresses the exit code of > git, hiding potential failures from the test suite. Capture the > output to a temporary file first, then count the lines separately > to preserve the exit code. > > Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> > --- > t/t1410-reflog.sh | 29 +++++++++++++++++++++-------- > 1 file changed, 21 insertions(+), 8 deletions(-) > > diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh > index ce71f9a30a..397f94b039 100755 > --- a/t/t1410-reflog.sh > +++ b/t/t1410-reflog.sh > @@ -244,8 +244,10 @@ 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) && > + git reflog >reflog_output && > + HEAD_entry_count=$(wc -l <reflog_output) && > + git reflog show main >reflog_main_output && > + main_entry_count=$(wc -l <reflog_main_output) && > > test $HEAD_entry_count = 5 && > test $main_entry_count = 5 && If you _know_ output from certain command must be 5 lines, would it make more sense to use test_stdout_line_count, perhaps like test_stdout_line_count = 5 git reflog or something? > @@ -254,16 +256,23 @@ test_expect_success 'delete' ' > git reflog delete main@{1} && > git reflog show main > output && > test_line_count = $(($main_entry_count - 1)) output && > - test $HEAD_entry_count = $(git reflog | wc -l) && > + git reflog >reflog_output && > + test $HEAD_entry_count = $(wc -l <reflog_output) && > ! 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) && > + git reflog >reflog_output && > + test $(($HEAD_entry_count -1)) = $(wc -l <reflog_output) && > + git reflog show main >reflog_main_output && > + test $main_entry_count = $(wc -l <reflog_main_output) && > + > + > + git reflog >reflog_output && > + HEAD_entry_count=$(wc -l <reflog_output) && > + > > - HEAD_entry_count=$(git reflog | wc -l) && > > git reflog delete main@{07.04.2005.15:15:00.-0700} && Can you explain the addition of these consecutive blank lines? The same question applies to the blank lines at the end of the test in the next hunk. I ask because formatting issues like this often resemble unedited AI-generated code that hasn't been properly cleaned up before submission. > git reflog show main > output && > @@ -321,11 +330,15 @@ 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 && > + git reflog main >reflog_output && > + test $(wc -l <reflog_output) = 4 && > git branch foo && > git pack-refs --all && > git checkout foo && > - test $(git reflog main | wc -l) = 4 > + git reflog main >reflog_output && > + test $(wc -l <reflog_output) = 4 > + > + > ' > > test_expect_success 'stale dirs do not cause d/f conflicts (reflogs on)' ' ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] t1410-reflog.sh: avoid suppressing git's exit code in pipelines 2026-07-07 2:16 ` Junio C Hamano @ 2026-07-07 13:55 ` Gatla Vishweshwar Reddy 2026-07-08 1:48 ` Junio C Hamano 2026-07-08 9:20 ` [PATCH v3] " Gatla Vishweshwar Reddy 1 sibling, 1 reply; 8+ messages in thread From: Gatla Vishweshwar Reddy @ 2026-07-07 13:55 UTC (permalink / raw) To: git; +Cc: Gatla Vishweshwar Reddy Piping git commands directly to wc -l suppresses the exit code of git, hiding potential failures from the test suite. Capture the output to a temporary file first, then count the lines separately to preserve the exit code. Where the expected count is known ahead of time, use test_stdout_line_count instead. Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> --- t/t1410-reflog.sh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index ce71f9a30a..8e018d172b 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -244,26 +244,30 @@ 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 && + git reflog >reflog_output && + HEAD_entry_count=$(wc -l <reflog_output) && + test_stdout_line_count = 5 git reflog show main && + git reflog show main >reflog_main_output && + main_entry_count=$(wc -l <reflog_main_output) && git reflog delete main@{1} && git reflog show main > output && test_line_count = $(($main_entry_count - 1)) output && - test $HEAD_entry_count = $(git reflog | wc -l) && + git reflog >reflog_output && + test $HEAD_entry_count = $(wc -l <reflog_output) && ! 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) && + git reflog >reflog_output && + test $(($HEAD_entry_count -1)) = $(wc -l <reflog_output) && + git reflog show main >reflog_main_output && + test $main_entry_count = $(wc -l <reflog_main_output) && - HEAD_entry_count=$(git reflog | wc -l) && + git reflog >reflog_output && + HEAD_entry_count=$(wc -l <reflog_output) && git reflog delete main@{07.04.2005.15:15:00.-0700} && git reflog show main > output && @@ -319,13 +323,12 @@ test_expect_success 'git reflog expire unknown reference' ' test_must_fail git reflog expire does-not-exist 2>stderr && test_grep "error: reflog could not be found: ${SQ}does-not-exist${SQ}" stderr ' - 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)' ' -- 2.54.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] t1410-reflog.sh: avoid suppressing git's exit code in pipelines 2026-07-07 13:55 ` [PATCH v2] " Gatla Vishweshwar Reddy @ 2026-07-08 1:48 ` Junio C Hamano 0 siblings, 0 replies; 8+ messages in thread From: Junio C Hamano @ 2026-07-08 1:48 UTC (permalink / raw) To: Gatla Vishweshwar Reddy; +Cc: git Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes: > Piping git commands directly to wc -l suppresses the exit code of > git, hiding potential failures from the test suite. Capture the > output to a temporary file first, then count the lines separately > to preserve the exit code. Where the expected count is known ahead > of time, use test_stdout_line_count instead. > > Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> > --- > t/t1410-reflog.sh | 29 ++++++++++++++++------------- > 1 file changed, 16 insertions(+), 13 deletions(-) The above descripotion looks reasonble. By the way, Documentation/SubmittingPatches has this: Before sending another version, make sure you have answered meaningful review comments in the existing discussion. Also give reviewers enough time to comment before sending another version. > diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh > index ce71f9a30a..8e018d172b 100755 > --- a/t/t1410-reflog.sh > +++ b/t/t1410-reflog.sh > @@ -244,26 +244,30 @@ 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 && > + git reflog >reflog_output && > + HEAD_entry_count=$(wc -l <reflog_output) && > + test_stdout_line_count = 5 git reflog show main && > + git reflog show main >reflog_main_output && > + main_entry_count=$(wc -l <reflog_main_output) && > > git reflog delete main@{1} && > git reflog show main > output && > test_line_count = $(($main_entry_count - 1)) output && > - test $HEAD_entry_count = $(git reflog | wc -l) && > + git reflog >reflog_output && > + test $HEAD_entry_count = $(wc -l <reflog_output) && > ! grep ox < output && Now, you no longer have new consecutive blank lines in the above, but the above shares the same "what did the author meant to convey with this blank line?" puzzlement. The updated code somehow wanders around in many directions like a drunken man. Let's comment on each line. > + test_stdout_line_count = 5 git reflog && This is "Does the reflog for HEAD have exactly 5 entries?" test. > + git reflog >reflog_output && > + HEAD_entry_count=$(wc -l <reflog_output) && As we already saw that HEAD_entry_count variable is exactly equal to 5, it is puzzling why we want to perform this computation again and assign the result to the variable. > + test_stdout_line_count = 5 git reflog show main && And then we check "Does the reflog for 'main' have exactly 5 entries?" > + git reflog show main >reflog_main_output && > + main_entry_count=$(wc -l <reflog_main_output) && And recompute what we already know and asssign to main_entry_count variable, which shares the same puzzlement. > > git reflog delete main@{1} && > git reflog show main > output && > test_line_count = $(($main_entry_count - 1)) output && Now, after a blank line, it goes on to test a completely different thing, which is "after deleting an entry in main's reflog, can we count how many there is, and does it match what we expect, which is the previous count minus 1"? Why should we even need to do so, when git reflog delete main@{1} && test_stdout_line_count = 4 git reflog show main && would do just fine? > - test $HEAD_entry_count = $(git reflog | wc -l) && > + git reflog >reflog_output && > + test $HEAD_entry_count = $(wc -l <reflog_output) && And then it comes back to test what we already know, i.e. "does the reflog for HEAD have 5 entries?". Which we tested earlier already. Are we interested in checking that "reflog delete main@{1}" does not affect the reflog for HEAD? If so, doing test_stdout_line_count = 5 git reflog && again here would be simpler, no? That way, there is no need to recompute and assign to the {HEAD,main}_entry_count variables in the earlier part of the tests. I guess the same comment applies to the remainder of this test, where it is checked that a removal from HEAD reflog does not affect the reflog of main. > 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) && > + git reflog >reflog_output && > + test $(($HEAD_entry_count -1)) = $(wc -l <reflog_output) && > + git reflog show main >reflog_main_output && > + test $main_entry_count = $(wc -l <reflog_main_output) && > > - HEAD_entry_count=$(git reflog | wc -l) && > + git reflog >reflog_output && > + HEAD_entry_count=$(wc -l <reflog_output) && > > git reflog delete main@{07.04.2005.15:15:00.-0700} && > git reflog show main > output && > @@ -319,13 +323,12 @@ test_expect_success 'git reflog expire unknown reference' ' > test_must_fail git reflog expire does-not-exist 2>stderr && > test_grep "error: reflog could not be found: ${SQ}does-not-exist${SQ}" stderr > ' > - > 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)' ' ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3] t1410-reflog.sh: avoid suppressing git's exit code in pipelines 2026-07-07 2:16 ` Junio C Hamano 2026-07-07 13:55 ` [PATCH v2] " Gatla Vishweshwar Reddy @ 2026-07-08 9:20 ` Gatla Vishweshwar Reddy 2026-07-08 20:41 ` Junio C Hamano 1 sibling, 1 reply; 8+ messages in thread From: Gatla Vishweshwar Reddy @ 2026-07-08 9:20 UTC (permalink / raw) To: git; +Cc: Gatla Vishweshwar Reddy Piping git commands directly to wc -l suppresses the exit code of git, hiding potential failures from the test suite. Capture the output to a temporary file first, then count the lines separately to preserve the exit code. Where the expected count is known ahead of time, use test_stdout_line_count instead. Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> --- Changes in v3: - Removed all variables (HEAD_entry_count, main_entry_count) entirely - Removed all temporary file captures (reflog_output, reflog_main_output) - Used test_stdout_line_count with hardcoded counts throughout - The counts are known ahead of time: HEAD=5, main=5 initially,decreasing as entries are deleted t/t1410-reflog.sh | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index ce71f9a30a..3f2e36cf33 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -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 ' @@ -319,13 +311,12 @@ test_expect_success 'git reflog expire unknown reference' ' test_must_fail git reflog expire does-not-exist 2>stderr && test_grep "error: reflog could not be found: ${SQ}does-not-exist${SQ}" stderr ' - 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)' ' -- 2.54.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3] t1410-reflog.sh: avoid suppressing git's exit code in pipelines 2026-07-08 9:20 ` [PATCH v3] " Gatla Vishweshwar Reddy @ 2026-07-08 20:41 ` Junio C Hamano 2026-07-09 5:09 ` [PATCH v4] " Gatla Vishweshwar Reddy 0 siblings, 1 reply; 8+ messages in thread From: Junio C Hamano @ 2026-07-08 20:41 UTC (permalink / raw) To: Gatla Vishweshwar Reddy; +Cc: git Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes: > Piping git commands directly to wc -l suppresses the exit code of > git, hiding potential failures from the test suite. Correct. > Capture the > output to a temporary file first, then count the lines separately > to preserve the exit code. Where the expected count is known ahead > of time, use test_stdout_line_count instead. Technically, the description is not telling any lies about the solution, but the patch no longer does the caputuring or counting itself at all. Rather, it exclusively uses test_stdout_line_count, which internally does the saving to a temporary and counting the lines ;-) The changes in the patch are mostly good, except for the loss of a blank line that separates two test pieces in the last hunk (below). > @@ -319,13 +311,12 @@ test_expect_success 'git reflog expire unknown reference' ' > test_must_fail git reflog expire does-not-exist 2>stderr && > test_grep "error: reflog could not be found: ${SQ}does-not-exist${SQ}" stderr > ' > - > 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)' ' Thanks. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4] t1410-reflog.sh: avoid suppressing git's exit code in pipelines 2026-07-08 20:41 ` Junio C Hamano @ 2026-07-09 5:09 ` Gatla Vishweshwar Reddy 2026-07-09 16:38 ` Junio C Hamano 0 siblings, 1 reply; 8+ messages in thread From: Gatla Vishweshwar Reddy @ 2026-07-09 5:09 UTC (permalink / raw) To: git; +Cc: Gatla Vishweshwar Reddy 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> --- Changes in v4: - Restored blank line between test_expect_success blocks that was accidentally removed in v2 - Updated commit message to accurately describe the solution Thank you for the detailed review! t/t1410-reflog.sh | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index ce71f9a30a..5a40a62ba2 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -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)' ' -- 2.54.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4] t1410-reflog.sh: avoid suppressing git's exit code in pipelines 2026-07-09 5:09 ` [PATCH v4] " Gatla Vishweshwar Reddy @ 2026-07-09 16:38 ` Junio C Hamano 0 siblings, 0 replies; 8+ messages in thread From: Junio C Hamano @ 2026-07-09 16:38 UTC (permalink / raw) To: Gatla Vishweshwar Reddy; +Cc: git Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes: > 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> > --- > > Changes in v4: > - Restored blank line between test_expect_success blocks that was > accidentally removed in v2 > - Updated commit message to accurately describe the solution This version looks good to me. Will queue and mark the topic for 'next'. Thanks. > > Thank you for the detailed review! > > t/t1410-reflog.sh | 26 +++++++++----------------- > 1 file changed, 9 insertions(+), 17 deletions(-) > > diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh > index ce71f9a30a..5a40a62ba2 100755 > --- a/t/t1410-reflog.sh > +++ b/t/t1410-reflog.sh > @@ -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)' ' ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-07-09 16:38 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-06 20:50 [PATCH] t1410-reflog.sh: avoid suppressing git's exit code in pipelines Gatla Vishweshwar Reddy 2026-07-07 2:16 ` Junio C Hamano 2026-07-07 13:55 ` [PATCH v2] " Gatla Vishweshwar Reddy 2026-07-08 1:48 ` Junio C Hamano 2026-07-08 9:20 ` [PATCH v3] " Gatla Vishweshwar Reddy 2026-07-08 20:41 ` Junio C Hamano 2026-07-09 5:09 ` [PATCH v4] " Gatla Vishweshwar Reddy 2026-07-09 16:38 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox