Move internal state dir to 'common' subdir in git path. (Fixes bug with multiple worktrees) #222
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows unlocked repos to work correctly with multiple worktrees.
When doing
git worktree add newtree2
in an "unlocked" repo, I get the following output and creating the new worktree fails.By putting
strace
in front of the smudge command in.git/config
, I see:Git is calling the smudge command when checking out the new working tree, which then fails to find the key file because
git rev-parse
uses a separate dir for each worktree. Hence theworktrees/newtree2
in the path. The command fails because there is nogit-crypt
dir in.git/worktrees/newtree2
.git rev-parse --git-path
should be used instead ofgit rev-parse --git-dir
, based on https://git-scm.com/docs/git-worktree#_details :More importantly,
git-crypt
should be using thecommon
subdir of the git dir to store in-use keys, since those need to be shared across workdirs. https://git-scm.com/docs/gitrepository-layout#Documentation/gitrepository-layout.txt-common