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

git worktree support #50

Open
flybyray opened this issue May 31, 2018 · 4 comments
Open

git worktree support #50

flybyray opened this issue May 31, 2018 · 4 comments
Labels
stale This issue has not received any feedback

Comments

@flybyray
Copy link

By using jgit from eclipse this plugin will fail when used within a git worktree.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=477475
possible fix:
https://git.eclipse.org/r/#/c/54404/
https://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02987.html

@dcoraboeuf
Copy link
Contributor

Hi,

Thanks for the feedback. Have you an easy way to reproduce your issue? I assume it's not actually linked to Eclipse but to the fact of using Git worktrees?

If you could describe how to reproduce your issue, that'd help fix it.

Thanks,
Damien

@dcoraboeuf dcoraboeuf added the stale This issue has not received any feedback label Sep 7, 2018
@leonard84
Copy link

The issue is quite simple to recreate, just checkout a normal project that uses this plugin and then create a worktree copy with git worktree add ../other master (you may have to use a different branch since you can only have one checkout of a branch). Then go to ../other and execute the build, it should throw something like this:

Caused by: org.eclipse.jgit.api.errors.NoHeadException: No HEAD exists and no explicit starting revision was specified
        at org.eclipse.jgit.api.LogCommand.call(LogCommand.java:150)
        at org.eclipse.jgit.api.LogCommand.call(LogCommand.java:1)
        at java_util_concurrent_Callable$call$0.call(Unknown Source)
        at org.ajoberstar.grgit.operation.LogOp.call(LogOp.groovy:64)
        at org.ajoberstar.grgit.operation.LogOp.call(LogOp.groovy)
        at java_util_concurrent_Callable$call.call(Unknown Source)
        at java_util_concurrent_Callable$call.call(Unknown Source)
        at org.ajoberstar.grgit.internal.OpSyntax.mapOperation(OpSyntax.groovy:20)
        at org.ajoberstar.grgit.internal.OpSyntax$mapOperation.callStatic(Unknown Source)
        at org.ajoberstar.grgit.Grgit.log(Grgit.groovy)
        at org.ajoberstar.grgit.Grgit$log$0.call(Unknown Source)
        at net.nemerosa.versioning.git.GitInfoService.getInfo(GitInfoService.groovy:53)
        at net.nemerosa.versioning.SCMInfoService$getInfo.call(Unknown Source)
        at net.nemerosa.versioning.VersioningExtension.computeInfo(VersioningExtension.groovy:195)
        at net.nemerosa.versioning.VersioningExtension.getInfo(VersioningExtension.groovy:182)
        at net.nemerosa.versioning.VersioningExtension_Decorated.getInfo(Unknown Source)

I encountered it while working on https://github.com/spockframework/spock

JGit still doesn't have a fix it seems: https://git.eclipse.org/r/#/c/126454/
However, you could add a workaround and check if .git is a file instead of a directory and then just inject a dummy version instance and log a warning. IMHO this is a good compromise, to be able to use worktrees, since you won't use them to release the dummy version shouldn't be such a problem.

@mohitmv
Copy link

mohitmv commented Nov 23, 2020

Hi, What is the latest status of git worktree support ?
My workflow is blocked because of this.

@jjlin
Copy link

jjlin commented Oct 28, 2024

Read support for worktrees was introduced recently in JGit 7, but it requires Java 17:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This issue has not received any feedback
Projects
None yet
Development

No branches or pull requests

5 participants