Skip to content

git-gui doesn't close stdin when executing hooks #55

@kmurphy4

Description

@kmurphy4

Hi! This is the first issue I've opened, so please let me know if you'd like any more information.

I'm running into an issue where git-gui will hang indefinitely after pressing Commit while executing a pre-commit hook. I've tracked this to a call to cat > ... in my hook. It seems to me that git-gui is not handling stdin to the child process correctly (this same hook doesn't fail on the command line).

Here's an example that hopefully makes it more clear:

(setup)

$ git init
$ cat > .git/hooks/pre-commit
#!/bin/bash
cat > x
$ chmod +x .git/hooks/pre-commit

(expected behavior -- this is what plain git does)

$ touch y
$ git add y
$ rm -f x
$ git commit -m "test"  # returns immediately
$ test -e x && echo created || echo failed
created

(actual behavior -- this is what git-gui does)

$ touch z
$ git add z
$ rm -f x
$ git gui  # Press "Commit" => hangs forever "Calling pre-commit hook..."

I don't see any way to close the stdin to the hook process, so it's impossible to commit using the GUI as-is. I've "solved" this by just adding calls to timeout when I cat, but that doesn't seem like a good long-term solution.

For the record, I'm aware that git won't send me data on stdin for the pre-commit hook, but certain hooks do send data this way (source):

Hooks can get their arguments via the environment, command-line arguments, and stdin. See the documentation for each hook below for details.

Here are the versions of the commands I'm using:

$ git --version
git version 2.31.1
$ git gui --version
git-gui version 0.21.0.99.gdf4f9e

I tried looking through the source, but I only got as far as _open_stdout_stderr since I don't know Tcl 😄

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions