Fix #150: Support git worktrees in JGit property source by gnodet · Pull Request #151 · maveniverse/nisse (original) (raw)

@gnodet @claude

JGit 5.x does not natively support git worktrees. When .git is a file (containing a gitdir: pointer) rather than a directory, FileRepositoryBuilder fails with RepositoryNotFoundException.

This fix detects worktrees by checking for the commondir file in the resolved git directory, redirects to the common (shared) git directory for access to objects/refs/tags, and reads HEAD from the worktree-specific directory to resolve the correct branch.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

[coderabbitai[bot]](/apps/coderabbitai)

@gnodet @claude

When resolveHead() returns null (empty repo with no commits), fall back to the default HEAD resolution which naturally throws NoHeadException, preserving the existing behavior for the 0-commits-0-tags integration test.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

[coderabbitai[bot]](/apps/coderabbitai)

@gnodet @claude

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

[coderabbitai[bot]](/apps/coderabbitai)

[coderabbitai[bot]](/apps/coderabbitai)

@coderabbitai

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit noreply@coderabbit.ai

[coderabbitai[bot]](/apps/coderabbitai)

@gnodet gnodet marked this pull request as draft

April 7, 2026 07:01

@gnodet @claude

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@gnodet gnodet marked this pull request as ready for review

April 7, 2026 07:11

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})