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

jgit upgrade to support git worktree #12910

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Oct 16, 2024

The comment in the diff explains everything.

See

Personally I make use of git worktree, I checked out the 3.0.x and and 2.9.x in separate folders. Until now I had to make a workaround by setting ThisBuild / com.github.sbt.git.SbtGit.GitKeys.gitUncommittedChanges := false otherwise sbt wont start up the project and you run into following exception:

Exception with jgit 5 (and 6) (click to expand)
$ sbt
[info] welcome to sbt 1.10.2 (Eclipse Adoptium Java 17.0.12)
[info] loading global plugins from /home/mkurz/.sbt/1.0/plugins
...
org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
        at org.eclipse.jgit.lib.Repository.getWorkTree(Repository.java:1570)
        at org.eclipse.jgit.treewalk.FileTreeIterator.<init>(FileTreeIterator.java:87)
        at org.eclipse.jgit.treewalk.FileTreeIterator.<init>(FileTreeIterator.java:73)
        at org.eclipse.jgit.api.StatusCommand.call(StatusCommand.java:113)
        at com.github.sbt.git.JGit.hasUncommittedChanges(JGit.scala:94)
        at com.github.sbt.git.SbtGit$.$anonfun$buildSettings$22(GitPlugin.scala:126)
        at com.github.sbt.git.SbtGit$.$anonfun$buildSettings$22$adapted(GitPlugin.scala:126)
        at com.github.sbt.git.DefaultReadableGit.withGit(ReadableGit.scala:44)
        at com.github.sbt.git.SbtGit$.$anonfun$buildSettings$21(GitPlugin.scala:126)
        at com.github.sbt.git.SbtGit$.$anonfun$buildSettings$21$adapted(GitPlugin.scala:126)
        at scala.Function1.$anonfun$compose$1(Function1.scala:49)
        at sbt.internal.util.EvaluateSettings$MixedNode.evaluate0(INode.scala:229)
        at sbt.internal.util.EvaluateSettings$INode.evaluate(INode.scala:171)
        at sbt.internal.util.EvaluateSettings.$anonfun$submitEvaluate$1(INode.scala:88)
        at sbt.internal.util.EvaluateSettings.sbt$internal$util$EvaluateSettings$$run0(INode.scala:100)
        at sbt.internal.util.EvaluateSettings$$anon$3.run(INode.scala:95)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840)
[error] org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
[error] Use 'last' for the full log.

sbt-git introduced a setting (useReadableConsoleGit) to avoid using jgit and fall back to command line git:

Also they want to soon detect if a project is checked out in a linked worktree or not and only disable jgit if you are:

However, if we just ugprade to jgit 7+ we can avoid all of that because it supports git worktree out of the box.
One of those small things that makes development just smoother out of the box...

@@ -0,0 +1 @@
addDependencyTreePlugin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah I added this so I can run dependencyBrowseTreeHTML in the meta-build. IMHO adding it to the meta-build does not hurt.

@mkurz mkurz force-pushed the jgit-upgrade_support_git-worktree branch from 3c079d4 to c6cb97b Compare October 16, 2024 13:29
@mkurz
Copy link
Member Author

mkurz commented Oct 17, 2024

Waiting for a reply in

to see if we need to set

ThisBuild / com.github.sbt.git.SbtGit.GitKeys.useConsoleForROGit := false

in build.sbt

@mkurz mkurz force-pushed the jgit-upgrade_support_git-worktree branch from c6cb97b to 25556a9 Compare October 25, 2024 07:03
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

Successfully merging this pull request may close these issues.

1 participant