Skip to content

Git GUI does not execute commit hooks when running from a secondary worktree #1755

@luismbo

Description

@luismbo
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.17.0.windows.1
cpu: x86_64
built from commit: e7621d891d081acff6acd1f0ba6ae0adce06dd09
sizeof-long: 4
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.17134.112]
  • What options did you set as part of the installation? Or did you choose the
    defaults?

Portable version.

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Hopefully, no.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Bash.

mkdir foo
cd foo
git init

# set up a commit-msg hook that appends "The End" to commit messages
echo -e '#!/bin/sh\necho "The End" >> "$1"' > .git/hooks/commit-msg

touch file
git add file
git gui # commit; the commit-msg hook runs

# another commit, this time from a worktree
git branch master2
git worktree add ../foo-worktree master2
cd ../foo-worktree
echo "some change" >> file
git add file
git gui # commit; the commit-msg hook does NOT run
  • What did you expect to occur after running these commands?

I expected the commit created in foo-worktree would have "The End" appended by the commit-msg hook.

  • What actually happened instead?

The commit-msg hook appears to not have been executed. The commit message does not end with "The End".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions