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

3 messages from 2019-04-01 to 2019-04-02. Participants: Jan Ziak, Johannes Schindelin.
Thread: https://gitlist.dev/t/50853

## Jan Ziak, 2019-04-01 13:57

Subject: git-gui: executed hooks are different from command-line git if hooksPath is set
Message-ID: <CAODFU0rSSeLReFKci_p3kjJwxD65R21syDTHoKcqWJ0wbF8jZQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAODFU0rSSeLReFKci_p3kjJwxD65R21syDTHoKcqWJ0wbF8jZQ%40mail.gmail.com

```
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, 2019-04-01 20:46

Subject: Re: git-gui: executed hooks are different from command-line git if hooksPath is set
Message-ID: <nycvar.QRO.7.76.6.1904012244520.41@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1904012244520.41%40tvgsbejvaqbjf.bet
In-Reply-To: <CAODFU0rSSeLReFKci_p3kjJwxD65R21syDTHoKcqWJ0wbF8jZQ@mail.gmail.com>

```
Hi Jan,

On Mon, 1 Apr 2019, Jan Ziak wrote:

> 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, 2019-04-02 23:35

Subject: Re: git-gui: executed hooks are different from command-line git if hooksPath is set
Message-ID: <CAODFU0q9-02k_OtHh8+fo-rm8AxpmaE_fqiEhoS2cmfrxrim=A@mail.gmail.com>
URL: https://gitlist.dev/e/CAODFU0q9-02k_OtHh8%2Bfo-rm8AxpmaE_fqiEhoS2cmfrxrim%3DA%40mail.gmail.com
In-Reply-To: <nycvar.QRO.7.76.6.1904012244520.41@tvgsbejvaqbjf.bet>

```
On Mon, 1 Apr 2019 at 22:46, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> 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

```
