git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[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

Next: Junio C Hamano
Message 1 of 5 in “[BUG?] applypatch-msg hook no-longer thinks stdin is a tty”
  1. Chris PackhamOct 1, 2015
  2. Junio C HamanoOct 2, 2015
  3. Junio C HamanoOct 2, 2015
  4. Chris PackhamOct 3, 2015
  5. Johannes SixtOct 3, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.