versioning icon indicating copy to clipboard operation
versioning copied to clipboard

git worktree support

Open flybyray opened this issue 7 years ago • 4 comments

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

flybyray avatar May 31 '18 23:05 flybyray

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 avatar Jun 01 '18 17:06 dcoraboeuf

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.

leonard84 avatar Dec 19 '18 13:12 leonard84

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

mohitmv avatar Nov 23 '20 15:11 mohitmv