From: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>
To: git@vger.kernel.org
Cc: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>
Subject: [PATCH] t1410-reflog.sh: avoid suppressing git's exit code in pipelines
Date: Tue, 7 Jul 2026 02:20:36 +0530 [thread overview]
Message-ID: <20260706205036.3453-1-gatlavishweshwarreddy26@gmail.com> (raw)
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
next reply other threads:[~2026-07-06 20:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 20:50 Gatla Vishweshwar Reddy [this message]
2026-07-07 2:16 ` [PATCH] t1410-reflog.sh: avoid suppressing git's exit code in pipelines 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260706205036.3453-1-gatlavishweshwarreddy26@gmail.com \
--to=gatlavishweshwarreddy26@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox