All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3] t1410-reflog.sh: avoid suppressing git's exit code in pipelines
Date: Wed, 08 Jul 2026 13:41:09 -0700	[thread overview]
Message-ID: <xmqqv7aprz8a.fsf@gitster.g> (raw)
In-Reply-To: <20260708092448.35776-1-gatlavishweshwarreddy26@gmail.com> (Gatla Vishweshwar Reddy's message of "Wed, 8 Jul 2026 14:50:05 +0530")

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.

  reply	other threads:[~2026-07-08 20:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=xmqqv7aprz8a.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.