git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t/lib-gpg: fix gpgconf stderr redirect to /dev/null

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 14, 2017, 02:49 UTC
Message-ID
<xmqq60ad7ewx.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171113210745.24638-1-tmz@pobox.com>
Todd Zullinger <tmz@pobox.com> writes:
Show 21 quoted lines
> In 29ff1f8f74 (t: lib-gpg: flush gpg agent on startup, 2017-07-20), a
> call to gpgconf was added to kill the gpg-agent.  The intention was to
> ignore all output from the call, but the order of the redirection needs
> to be switched to ensure that both stdout and stderr are redirected to
> /dev/null.  Without this, gpgconf from gnupg-2.0 releases would output
> 'gpgconf: invalid option "--kill"' each time it was called.
>
> Signed-off-by: Todd Zullinger <tmz@pobox.com>
> ---
>
> I noticed that gpgconf produced error output for a number of tests on
> CentOS/RHEL.  As an example:
>
>     *** t5534-push-signed.sh ***
>     gpgconf: invalid option "--kill"
>
> Looking at the code in lib-gpg.sh, it appeared the intention was to ignore this
> output.  Reading through the review of the patch confirmed that feeling[1].  The
> current code gets caught by the subtleties of output redirection.  (Who hasn't
> been burned at some point by the difference between '2>&1 >/dev/null' and
> '>/dev/null 2>&1' ? ;)
**Blush**.  I should have caught this during the review.  Thanks.
Show 15 quoted lines
> Lastly, I also noticed that git-rebase.sh uses the same 2>&1 >/dev/null.  I
> suspect it's similarly not intentional:
>
>     $ git grep -h -C4 '2>&1 >/dev/null' -- git-rebase.sh
>     apply_autostash () {
>     	if test -f "$state_dir/autostash"
>     	then
>     		stash_sha1=$(cat "$state_dir/autostash")
>     		if git stash apply $stash_sha1 2>&1 >/dev/null
>     		then
>     			echo "$(gettext 'Applied autostash.')" >&2
>     		else
>     			git stash store -m "autostash" -q $stash_sha1 ||
>
> I'll send a separate patch to adjust that code as well.

If it were intentional, the caller of apply_autostash() must be expecting to see an error message from its standard output and prepared to do something interesting with it, which I do not see, so I agree that it is a typo. Thanks.

I wonder if this line in 3320 is doing what it meant to do:
    test_must_fail git notes merge z 2>&1 >out &&
    test_i18ngrep "Automatic notes merge failed" out &&
    grep -v "A notes merge into refs/notes/x is already in-progress in" out
Previous: Santiago TorresNext: Todd Zullinger
Message 8 of 16 in “t/lib-gpg: fix gpgconf stderr redirect to /dev/null”
  1. t/lib-gpg: fix gpgconf stderr redirect to /dev/nullTodd Zullinger, Nov 13, 2017
  2. Santiago TorresNov 13, 2017
  3. Todd ZullingerNov 13, 2017
  4. Santiago TorresNov 13, 2017
  5. Santiago TorresNov 13, 2017
  6. Todd ZullingerNov 14, 2017
  7. Santiago TorresNov 14, 2017
  8. Junio C HamanoNov 14, 2017
  9. Todd ZullingerNov 14, 2017
  10. Junio C HamanoNov 14, 2017
  11. Todd ZullingerNov 14, 2017
  12. Johan HerlandNov 14, 2017
  13. Junio C HamanoNov 14, 2017
  14. notes: send "Automatic notes merge failed" messages to stderrTodd Zullinger, Nov 14, 2017
  15. Johan HerlandNov 15, 2017
  16. Todd ZullingerNov 15, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.