From: Jeff King <peff@peff.net>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Duy Nguyen <pclouds@gmail.com>,
Git Mailing List <git@vger.kernel.org>,
Stefan Beller <sbeller@google.com>,
Anthony Sottile <asottile@umich.edu>
Subject: Re: [PATCH v2 0/3] nd/clear-gitenv-upon-use-of-alias
Date: Wed, 23 Dec 2015 16:31:40 -0500 [thread overview]
Message-ID: <20151223213140.GB21277@sigill.intra.peff.net> (raw)
In-Reply-To: <567B05F0.5020604@kdbg.org>
On Wed, Dec 23, 2015 at 09:37:04PM +0100, Johannes Sixt wrote:
> >--- a/git.c
> >+++ b/git.c
> >@@ -252,7 +252,7 @@ static int handle_alias(int *argcp, const char ***argv)
> > alias_argv[argc] = NULL;
> >
> > ret = run_command_v_opt(alias_argv, RUN_USING_SHELL);
> >- if (ret >= 0) /* normal exit */
> >+ if (ret != -1) /* normal exit */
>
> Why does this make a difference? We only ever return -1, zero, or a positive
> value from run_command/finish_command/wait_or_whine, as far as I can see.
Yeah, you're right. This bit predates 709ca73 (run-command: encode
signal death as a positive integer, 2013-01-05), which came out of the
same discussion. So I'd agree this hunk can simply be dropped.
That leaves the ignoring of SIGPIPE in wait_or_whine. I started to
rewrite the commit message to drop the first hunk, but I found I
couldn't replicate the problem in the second either!
Doing:
GIT_PAGER=false git -c alias.foo='!git log -p' foo
doesn't trigger it. We run the alias through a shell, so we see only the
munged "141" value from the shell's exit code.
Something like:
GIT_PAGER=false git -p -c alias.foo='!yes' foo
does generate the error message. But we've redirected stderr into the
pager at that point, so by definition it can never be shown.
So I think we would need a case where:
- the outer git doesn't run the pager that dies; instead the pager is
run inside the alias. But...
- inside the alias cannot be a shell pipeline, since "foo | less" will
report the exit code of "less", not "foo" (we make special arrangements
in git to propagate the exit code of "foo"). So it pretty much has
to be a git invocation inside the alias. But...
- The git invocation will convert signal death in the sub-process into
141, like a shell would.
So I'm not sure if this is triggerable at all with an alias.
I did manage to trigger it with an external command, like:
$ cat $(which git-yes)
#!/bin/sh
# This _has_ to be exec, otherwise the shell converts SIGPIPE death
# into 141.
exec yes
and then if you run your _own_ pager, like this:
$ git yes | false
error: git-yes died of signal 13
you see it. But if git starts the pager, you don't:
$ GIT_PAGER=false git -p yes
Because the stderr of the outer git process is going to the same dead
pipe.
So my takeaways are:
1. Complaining about signal death in general is going to be flaky,
because it's so easy for shells or git to rewrite the exit code and
not trigger WIFSIGNALED() in the first place.
2. I doubt anybody is actually seeing this in practice anymore. But
maybe I am misunderstanding something in Duy's series that changes
this.
-Peff
next prev parent reply other threads:[~2015-12-23 21:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CA+dzEB=2LJXiLSTqyLw8AeHNwdQicwvEiMg=hVEX0-_s1bySpA@mail.gmail.com>
2015-11-24 2:22 ` Fwd: Git clone fails during pre-commit hook due to GIT_WORK_TREE=. (regression 2.5 -> 2.6) Anthony Sottile
2015-11-24 17:57 ` Stefan Beller
2015-11-25 20:13 ` Duy Nguyen
2015-11-30 19:01 ` Duy Nguyen
2015-11-30 20:16 ` Junio C Hamano
2015-12-01 17:59 ` Duy Nguyen
2015-12-02 17:09 ` Junio C Hamano
2015-12-03 18:17 ` [PATCH 1/2] git.c: make it clear save_env() is for alias handling only Nguyễn Thái Ngọc Duy
2015-12-03 18:17 ` [PATCH 2/2] setup.c: re-fix d95138e (setup: set env $GIT_WORK_TREE when Nguyễn Thái Ngọc Duy
2015-12-04 20:35 ` Junio C Hamano
2015-12-05 5:48 ` Duy Nguyen
2015-12-05 15:32 ` [PATCH 3/2] git.c: make sure we do not leak GIT_* to alias scripts Nguyễn Thái Ngọc Duy
2015-12-07 18:54 ` Junio C Hamano
2015-12-08 16:55 ` Duy Nguyen
2015-12-08 17:20 ` Jeff King
2015-12-08 23:55 ` Junio C Hamano
2015-12-05 19:12 ` [PATCH 2/2] setup.c: re-fix d95138e (setup: set env $GIT_WORK_TREE when Duy Nguyen
2015-12-07 18:33 ` Junio C Hamano
2015-12-20 7:50 ` [PATCH v2 0/3] nd/clear-gitenv-upon-use-of-alias Nguyễn Thái Ngọc Duy
2015-12-20 7:50 ` [PATCH v2 1/3] git.c: make it clear save_env() is for alias handling only Nguyễn Thái Ngọc Duy
2015-12-20 7:50 ` [PATCH v2 2/3] setup.c: re-fix d95138e (setup: set env $GIT_WORK_TREE when Nguyễn Thái Ngọc Duy
2015-12-20 7:50 ` [PATCH v2 3/3] git.c: make sure we do not leak GIT_* to alias scripts Nguyễn Thái Ngọc Duy
2015-12-21 21:18 ` [PATCH v2 0/3] nd/clear-gitenv-upon-use-of-alias Junio C Hamano
2015-12-22 10:57 ` Duy Nguyen
2015-12-22 11:53 ` Duy Nguyen
2015-12-22 18:13 ` Junio C Hamano
2015-12-23 9:37 ` Jeff King
2015-12-23 10:20 ` Duy Nguyen
2015-12-23 16:17 ` Eric Sunshine
2015-12-23 20:37 ` Johannes Sixt
2015-12-23 21:31 ` Jeff King [this message]
2015-12-24 9:35 ` Duy Nguyen
2015-12-29 8:12 ` Jeff King
2015-12-29 21:34 ` Junio C Hamano
2015-12-21 10:22 ` [PATCH] Revert "setup: set env $GIT_WORK_TREE when work tree is set, like $GIT_DIR" Nguyễn Thái Ngọc Duy
2015-12-21 17:28 ` Junio C Hamano
2015-12-21 18:31 ` Junio C Hamano
2015-12-22 1:06 ` Duy Nguyen
2015-12-22 21:50 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151223213140.GB21277@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=asottile@umich.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=pclouds@gmail.com \
--cc=sbeller@google.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).