Re: [PATCH v4 1/2] hooks: allow input from stdin for commit-related hooks
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Nov 20, 2020, 06:48 UTC
- Message-ID
- <CAPig+cTaV-L_m3OFw=WAUKaiLqSVvhP7fjjFbE13QStibVmRjw@mail.gmail.com>
- In-Reply-To
- <CAPig+cS5BUCaFN=MN+7gSTbvskffRdTJOgck6TrRRacxCc_CwA@mail.gmail.com>
On Fri, Nov 20, 2020 at 1:38 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 13 quoted lines
> 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).