Skip to content

Commit c4fcd50

Browse files
Gatla Vishweshwar Reddygitster
authored andcommitted
t1410-reflog.sh: avoid suppressing git's exit code in pipelines
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>
1 parent f85a7e6 commit c4fcd50

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

t/t1410-reflog.sh

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,30 +244,22 @@ test_expect_success 'delete' '
244244
test_tick &&
245245
git commit -m tiger C &&
246246
247-
HEAD_entry_count=$(git reflog | wc -l) &&
248-
main_entry_count=$(git reflog show main | wc -l) &&
249-
250-
test $HEAD_entry_count = 5 &&
251-
test $main_entry_count = 5 &&
252-
247+
test_stdout_line_count = 5 git reflog &&
248+
test_stdout_line_count = 5 git reflog show main &&
253249
254250
git reflog delete main@{1} &&
251+
test_stdout_line_count = 4 git reflog show main &&
252+
test_stdout_line_count = 5 git reflog &&
255253
git reflog show main > output &&
256-
test_line_count = $(($main_entry_count - 1)) output &&
257-
test $HEAD_entry_count = $(git reflog | wc -l) &&
258254
! grep ox < output &&
259255
260-
main_entry_count=$(wc -l < output) &&
261-
262256
git reflog delete HEAD@{1} &&
263-
test $(($HEAD_entry_count -1)) = $(git reflog | wc -l) &&
264-
test $main_entry_count = $(git reflog show main | wc -l) &&
265-
266-
HEAD_entry_count=$(git reflog | wc -l) &&
257+
test_stdout_line_count = 4 git reflog &&
258+
test_stdout_line_count = 4 git reflog show main &&
267259
268260
git reflog delete main@{07.04.2005.15:15:00.-0700} &&
261+
test_stdout_line_count = 3 git reflog show main &&
269262
git reflog show main > output &&
270-
test_line_count = $(($main_entry_count - 1)) output &&
271263
! grep dragon < output
272264
273265
'
@@ -321,11 +313,11 @@ test_expect_success 'git reflog expire unknown reference' '
321313
'
322314

323315
test_expect_success 'checkout should not delete log for packed ref' '
324-
test $(git reflog main | wc -l) = 4 &&
316+
test_stdout_line_count = 4 git reflog main &&
325317
git branch foo &&
326318
git pack-refs --all &&
327319
git checkout foo &&
328-
test $(git reflog main | wc -l) = 4
320+
test_stdout_line_count = 4 git reflog main
329321
'
330322

331323
test_expect_success 'stale dirs do not cause d/f conflicts (reflogs on)' '

0 commit comments

Comments
 (0)