-
Notifications
You must be signed in to change notification settings - Fork 458
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
ratchetFrom
gives 'Cannot find git repository in any parent directory' if using Git worktrees
#964
Comments
Tracing through the code by eye (because it doesn't look like spotless runs the current code against itself when running spotlessCheck but rather downloads the latest stable to run the check...)
So is the fix like this:
|
I like the pseudocode for your workaround! This is a dupe of #75. Happy to take PR which incorporates a workaround of this sort, previously we've focused on getting a fix into the upstream JGit, but I don't think that's going to happen. |
Huh, I wonder why I couldn't find that ticket when I searched before filing |
If the directory found as the git dir contains a file called `gitdir`, attempts to resolve it to find the actual git directory. For issue diffplug#75 or my issue diffplug#964
If the directory found as the git dir contains a file called `gitdir`, attempts to resolve it to find the actual git directory. For issue diffplug#75 or my issue diffplug#964
Unifies logic in `GitRatchet` and `GitAttributesLineEndings` for finding the `.git` directory, into a new `GitWorkarounds` class, so both of these can now have the same workaround code for dealing with JGit not supporting worktrees. The actual workaround works by using `FileRepositoryBuilder` to find what it thinks is the `.git` directory, and then looking inside that to see if it contains a file called `gitdir`, which indicates the location of the true `.git` directory in the case of a git worktree. For issue diffplug#75 or my issue diffplug#964
At work, where I use worktrees to keep track of multiple in-progress changes, trying to use
ratchetFrom
results in an error:Versions in play at work:
For the sake of ease of reproduction I might as well try to reproduce it on the spotless project itself though, so here I have:
Reproduction steps:
git checkout master
git pull --ff-only
(just to make sure you're on latest)git branch new-dev-branch
git worktree add ../spotless-new-dev-branch new-dev-branch
cd ../spotless-new-dev-branch
./gradlew spotlessCheck
Result: the error posted above.
Full stack:
If you are submitting a bug, please include the following:
gradlew spotless[Apply/Check] --stacktrace
If you're just submitting a feature request or question, no need for the above.
The text was updated successfully, but these errors were encountered: