-
Notifications
You must be signed in to change notification settings - Fork 455
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
Spotless fails with an exception if the project is checked out using the git worktree functionality #75
Comments
Even if JGit doesn't fully support worktree, I'm sure it would be possible for Spotless to workaround the issue on its own. Here's the logic in question, which would need to manually detect when git worktree is being used. PR's welcome! |
Looks like JGit 5.1 might have worktree support. TBD: https://bugs.eclipse.org/bugs/show_bug.cgi?id=477475 |
Didn't make it into 5.1, but it's still being worked on. https://git.eclipse.org/r/#/c/126454/ |
It's being worked on again! |
It appears the code is initializing a repository with a FileRepositoryBuilder and this is likely part of the problem. The FileRepositoryBuilder seems to default to bare repos. Using the Git object could possibly workaround this issue.
|
@nedtwigg Can you provide any guidance? My workflow requires worktrees and the company I work for has adopted this plugin. I'm happy to make the contribution if you can give some pointers on how I can get to an approvable pull request. |
It's a limitation in JGit. If you look at the links above, you'll see the |
Thank you! |
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
Thanks to a creative PR from @hakanai, this issue might be solved in
If it doesn't work, post a stacktrace. |
What I have found after some more testing: for some of my work projects, the |
Further fixed in |
There is a RFE filed for JGit at https://bugs.eclipse.org/bugs/show_bug.cgi?id=477475
Maybe there is something that can be done in Spotless besides forcing me to either disable Spotless or making a full clone for the working tree?
Stacktrace is:
The text was updated successfully, but these errors were encountered: