[BUG?] applypatch-msg hook no-longer thinks stdin is a tty
- From
Chris Packham <judge.packham@gmail.com>
- Date
- Oct 1, 2015, 03:42 UTC
- Message-ID
- <CAFOYHZArBv=2E_YonCqOSC4mWk9=xkbG9FyB+zNFFAqmUBUKHA@mail.gmail.com>
Hi,
I have a applypatch-msg hook that implements some policy for acceptable commit messages and reject non-conformant patches. It also is able to prompt me to override it's rejection. The prompting only happens when stdin is a tty (as determined by pythons sys.stdin.isatty())
For example this would reject the patch and cause am stop $ cat bad.patch | git am
And this would prompt me to allow the patch and am would proceed if I answer Y $ git am bad.patch Patch message invalid apply (Y/N)?
As of git 2.6 this has stopped working and stdin always fails the tty check. Here's a minimal reproduction
$ cat >.git/hooks/applypatch-msg <<EOF
#!/usr/bin/env python
import sys
if sys.stdin.isatty():
print("TTY")
else:
print("NOT")
EOF
$ chmod +x .git/hooks/applypatch-msg$ git checkout -b temp origin/master^ $ git format-patch master -1
# With git 2.6 $ git am 0001-Git-2.6.patch NOT Applying: Git 2.6
# With git 2.5.3 TTY Applying: Git 2.6
Thanks, Chris