git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Tom Hale <tom@hale.ee>
Cc: Junio C Hamano <gitster@pobox.com>, git <git@vger.kernel.org>
Subject: Re: [PATCH] __git_ps1: Don't kill shell if user types `set -e`
Date: Thu, 4 May 2017 11:16:57 +0200	[thread overview]
Message-ID: <CACBZZX6XdwND2-7cY0zp8+K_uh60tn-i_r9V7HAe2X-a-RJeQA@mail.gmail.com> (raw)
In-Reply-To: <c8879806-4e43-d033-bd69-918e730e2d05@hale.ee>

On Thu, May 4, 2017 at 10:26 AM, Tom Hale <tom@hale.ee> wrote:
>
> On 17/04/17 11:24, Junio C Hamano wrote:
>> "Tom \"Ravi\" Hale" <tom@hale.ee> writes:
>>
>> > If a user types `set -e` in an interactive shell, and is using __git_ps1
>> > to set
>> > their prompt, the shell will die if the current directory isn't inside a git
>> > repository.
>> >
>> Hmph.  So the fix would be something like this?
>>
>>      repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
>>          --is-bare-repository --is-inside-work-tree \
>> -         --short HEAD 2>/dev/null)"
>> +         --short HEAD 2>/dev/null || :)"
>
> Nope, that would cause the next line
>     rev_parse_exit_code="$?"
> to always be assigned 0.
>
> I believe the patch we're after is attached.

I see how this would fix things, but this just seems like a rather
crazy thing for us to support, we can take this patch, but it's going
to take quite some maintenance burden to ensure that this code is set
-e clean going forward, and I don't think we should take a patch like
this without some general support in the regression tests to ensure
that the completion code is set -e clean, otherwise this is going to
very easily regress the next time someone not aware of this patches
it.

What's the real use-case here? If you do "set -e" in your shell you
also get e.g.:

    $ ls -l blah
    ls: cannot access blah: No such file or directory
    === Command terminated with exit status 2 (Thu May  4 11:16:03 2017) ===

I.e. any little failure will terminate your shell, are you actually
running a shell like this? For what purpose?

  reply	other threads:[~2017-05-04  9:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-16  8:28 [PATCH] __git_ps1: Don't kill shell if user types `set -e` Tom "Ravi" Hale
2017-04-17  4:24 ` Junio C Hamano
2017-05-04  8:26   ` Tom Hale
2017-05-04  9:16     ` Ævar Arnfjörð Bjarmason [this message]
2017-05-04  9:35       ` Tom Hale

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=CACBZZX6XdwND2-7cY0zp8+K_uh60tn-i_r9V7HAe2X-a-RJeQA@mail.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tom@hale.ee \
    /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).