-
Notifications
You must be signed in to change notification settings - Fork 55
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
Implement a better heuristic for Git worktrees #21
base: master
Are you sure you want to change the base?
Conversation
The existing heuristic for handling worktrees assumes that one other worktree contains a ".git" subdirectory with the Git database. This heuristic fails when worktrees are attached to a bare repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do worktrees work in this case? The “main” repo is bare and the other branches are normal directories?
This change seems to break a couple of tests: https://travis-ci.com/barisione/clang-format-hooks/jobs/234482995
In #13 somebody suggested the use of https://git-scm.com/docs/git-config#git-config-corehooksPath. Maybe we could conditionally use that (conditionally as some older git versions don't have it).
fi | ||
fi | ||
|
||
if [ -d "$top_dir/hooks" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there's a directory called hooks in the repository?
Correct. Just to make sure that random scripts don't go beserk editing the contents of the .git folder, we store that in a separate place as a bare repo, then add worktrees where the real editing is done.
I glanced at the errors, but it looked complicated so I didn't get a chance to try and debug it - I am traveling for the next two weeks.
By default, that does not return anything (tried it both in a worktree and in a cloned repo). I believe it returns a value if it was set (in order to use the hooks from a custom place.) |
For completeness, I have tested it with git 2.23 on Linux. |
The existing heuristic for handling worktrees assumes that one other
worktree contains a ".git" subdirectory with the Git database. This
heuristic fails when worktrees are attached to a bare repository.