Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit message hook not working with work-trees #143

Open
Rossi1337 opened this issue Feb 28, 2025 · 0 comments
Open

Commit message hook not working with work-trees #143

Rossi1337 opened this issue Feb 28, 2025 · 0 comments

Comments

@Rossi1337
Copy link

Version

7.0.0.202409031743-r

Operating System

Windows

Bug description

Not sure if this is a bug or more a feature request.
We use Eclipse with work-trees. This is not fully supported yet but works when you create the worktrees on the command line. Checkout branch A into one worktree and checkout branch B into another one.

Now you can open branch A in one Eclipse workspace and branch B in another. Committing pulling and pushing all works. But we have an issue with commit hooks.

We have activated a commit message hook. This works on the first worktree A but not on B.
The command line parameter $1 which should point to the file with the commit message is "empty".

When committing on branch A the file is passed to the hook as .git/COMMIT_EDITMSG that works fine.
But on B it does not work. Most likely because then the file will be written to .git\worktrees\branch-B\COMMIT_EDITMSG and the code that invokes the commit hook does not look there? Just guessing for now but this is what I think is going wrong and why the parameter is empty.

How to reproduce:

With git command line tools

  • On a repo checkout branch A into a folder
  • Checkout another branch B into another folder as separate work-tree
  • Activate commit hook support: may need some additional setup on Windows with Cygwin

With Eclipse

  • Create workspace A and import projects

  • Create another workspace B and import projects

  • Do a change in workspace 1 and commit it in Eclipse

  • Check the printed message and it will be .git/COMMIT_EDITMSG

  • Create a simple commit hook in .git/hooks/commit-msg to print $1

  • Do a change in workspace B and commit it in Eclipse

  • Check the printed message and it will be empty

Actual behavior

commit-msg commit hook is not invoked correctly when work-trees are involved. The parameter to pass the COMMIT_EDITMSG file is empty.

Expected behavior

The commit-msg script should be invoked with parameter 1 pointing to the correct COMMIT_EDITMSG file in the work-trees folder.

Relevant log output

Other information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant