All of lore.kernel.org
 help / color / mirror / Atom feed
From: Orgad Shaneh <orgads@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Orgad Shaneh via GitGitGadget <gitgitgadget@gmail.com>,
	Git List <git@vger.kernel.org>
Subject: Re: [PATCH v4 1/2] hooks: allow input from stdin for commit-related hooks
Date: Fri, 20 Nov 2020 09:16:27 +0200	[thread overview]
Message-ID: <CAGHpTB+2SV_GZT9QBSOQLYCO4znBCToCRJ5-guWMxxuQD+aA-w@mail.gmail.com> (raw)
In-Reply-To: <CAPig+cTaV-L_m3OFw=WAUKaiLqSVvhP7fjjFbE13QStibVmRjw@mail.gmail.com>

On Fri, Nov 20, 2020 at 8:49 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Fri, Nov 20, 2020 at 1:38 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > I do find it quite concerning that the way this series handles the
> > stdin conflict between the hook and `-F -` can break the hook silently
> > and mysteriously. How confusing for a user to write a hook which works
> > with `git commit -m msg` and `git commit -F file` but breaks silently
> > with `git commit -F -`. What is worse is that this breakage may be
> > outside the user's control. For instance, it is easy to imagine some
> > IDE passing the commit message to git-commit via stdin (using `-F -`)
> > rather than via a file (using `-F file`).
> >
> > At the very least, this change deserves a documentation update, both
> > to explain that the prepare-commit-msg hook has a valid stdin, and
> > (importantly) that it won't be able to rely upon stdin in conjunction
> > with `-F -`.
>
> What I forgot to say here was that this patch series doesn't help
> users at all if their IDE passes the commit message to git-commit via
> stdin using `-F -`. In such a case, their hook will _never_ see a
> valid stdin coming from Git, no matter what their script does. So, the
> change made by this patch series may help some users but not others,
> and this is a limitation that should be stated in the commit message
> (and perhaps mentioned in the documentation, though that may be
> difficult to do in a general way).

At least in my case, I never expect stdin to be available when running
in the IDE, so my hook is expected to use GUI anyway. I only need
stdin when the user is running git from the terminal. So all I need from
the IDE is that it doesn't pretend to be a tty while running Git.

And regarding the hook itself - the hook author should be aware that
stdin is not always a tty, and sometimes can be closed or pipe, and
write the hook in a way that handles special cases.

- Orgad

  reply	other threads:[~2020-11-20  7:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 15:02 [PATCH] hooks: allow input from stdin Orgad Shaneh via GitGitGadget
2020-11-17 19:59 ` Junio C Hamano
2020-11-19 15:50 ` [PATCH v2] " Orgad Shaneh via GitGitGadget
2020-11-19 15:56   ` [PATCH v3] hooks: allow input from stdin for commit-related hooks Orgad Shaneh via GitGitGadget
2020-11-19 19:16     ` Junio C Hamano
2020-11-19 20:41       ` Orgad Shaneh
2020-11-19 20:56     ` [PATCH v4 0/2] " Orgad Shaneh via GitGitGadget
2020-11-19 20:56       ` [PATCH v4 1/2] " Orgad Shaneh via GitGitGadget
2020-11-19 21:23         ` Eric Sunshine
2020-11-19 21:32           ` Junio C Hamano
2020-11-20  5:23           ` Orgad Shaneh
2020-11-20  6:38             ` Eric Sunshine
2020-11-20  6:48               ` Eric Sunshine
2020-11-20  7:16                 ` Orgad Shaneh [this message]
2020-11-20 18:13               ` Junio C Hamano
2020-11-20 10:59             ` Ævar Arnfjörð Bjarmason
2020-11-20 12:34               ` Orgad Shaneh
2020-11-19 20:56       ` [PATCH v4 2/2] commit: fix stdin conflict between message and hook Orgad Shaneh via GitGitGadget
2020-12-09 20:06       ` [PATCH v5 0/2] hooks: allow input from stdin for commit-related hooks Orgad Shaneh via GitGitGadget
2020-12-09 20:06         ` [PATCH v5 1/2] hooks: lay foundations for passing stdin to hooks Orgad Shaneh via GitGitGadget
2020-12-09 20:06         ` [PATCH v5 2/2] hooks: allow input from stdin for commit-related hooks Orgad Shaneh via GitGitGadget
2020-12-09 22:37           ` 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=CAGHpTB+2SV_GZT9QBSOQLYCO4znBCToCRJ5-guWMxxuQD+aA-w@mail.gmail.com \
    --to=orgads@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=sunshine@sunshineco.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.
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.