threads / discuss / 50853

git-gui: executed hooks are different from command-line git if hooksPath is set

Subject: git-gui: executed hooks are different from command-line git if hooksPath is set

## tl;dr

3 messages between Apr 1, 2019 and Apr 2, 2019.

replies: 2people: 2as markdown or json

Jan Ziak· Apr 1, 2019, 13:57 UTC · lore
Hello

Command-line "git commit" and graphical "git gui" commit are invoking different hooks if hooksPath is set in $HOME/.gitconfig.

Namely, in my case command-line "git commit" runs "/home/atom/dev/git-hooks/post-commit" - while "git gui" commit runs ".git/hooks/post-commit".

Please run the attached shell script in an empty directory to reproduce this issue. The script is using strace to determine which hook is being executed. The script will run "git gui": the user is expected to simply commit changes from the gui and then close the gui for the script to finish.

Script output:
  command-line: access("/home/atom/dev/git-hooks/post-commit", X_OK)
  gui: access(".git/hooks/post-commit", X_OK)
$ cat ~/.gitconfig
[core]
    hooksPath = /home/atom/dev/git-hooks
git version 2.21.0

Sincerely Jan

Johannes Schindelin· Apr 1, 2019, 20:46 UTC · re: Jan Ziak · lore

Re: git-gui: executed hooks are different from command-line git if hooksPath is set

Hi Jan,
On Mon, 1 Apr 2019, Jan Ziak wrote:
Show 20 quoted lines
> Command-line "git commit" and graphical "git gui" commit are invoking
> different hooks if hooksPath is set in $HOME/.gitconfig.
>
> Namely, in my case command-line "git commit" runs
> "/home/atom/dev/git-hooks/post-commit" - while "git gui" commit runs
> ".git/hooks/post-commit".
>
> Please run the attached shell script in an empty directory to
> reproduce this issue. The script is using strace to determine which
> hook is being executed. The script will run "git gui": the user is
> expected to simply commit changes from the gui and then close the gui
> for the script to finish.
>
> Script output:
>   command-line: access("/home/atom/dev/git-hooks/post-commit", X_OK)
>   gui: access(".git/hooks/post-commit", X_OK)
>
> $ cat ~/.gitconfig
> [core]
>     hooksPath = /home/atom/dev/git-hooks

Could you give `master` of https://github.com/git-for-windows/git a try? (Despite the name, we aim to keep it functional on the same platforms as Git itself.)

I am fairly certain that I fixed it there, and contributed a PR to the Git GUI project, but it seems that that project is in a kind of hibernating state right now.

Ciao, Johannes

Jan Ziak· Apr 2, 2019, 23:35 UTC · re: Johannes Schindelin · lore

Re: git-gui: executed hooks are different from command-line git if hooksPath is set

On Mon, 1 Apr 2019 at 22:46, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 7 quoted lines
> Could you give `master` of https://github.com/git-for-windows/git a try?
> (Despite the name, we aim to keep it functional on the same platforms as
> Git itself.)
>
> I am fairly certain that I fixed it there, and contributed a PR to the Git
> GUI project, but it seems that that project is in a kind of hibernating
> state right now.
Hello Johannes

You are right. git-gui.sh in `master` of https://github.com/git-for-windows/git is respecting the hooksPath specified in ~/.gitconfig.

Executing "git-for-windows/git rev-parse --git-path hooks/post-commit" as part of the process works fine but it seems a bit inefficient.

Sincerely Jan

← back to recent threads