Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Can not open worktrees
Can not open worktrees [message #1802142] Fri, 01 February 2019 18:24 Go to next message
nice robot is currently offline nice robotFriend
Messages: 3
Registered: February 2019
Junior Member
It seems i've tried every combination of FileRepositoryBuilder and Git.open to get access to worktrees but all attempts fail with RepositoryNotFoundException. Is there a generic means of find and opening the repository simply based on PWD?

From within the worktree folder, i've tried every combination between the setGitDir and setWorkTree commented lines:

	var repository = FileRepositoryBuilder()
		.setMustExist(true)
//      .setGitDir(File("."))
//      .setGitDir(File("./.git"))
//      .setGitDir(File("../parent/.git/worktrees/test"))
//      .setWorkTree(File("."))
//      .setWorkTree(File("./.git"))
		.readEnvironment()
		.findGitDir(
		.build()




  • .setGitDir(File(".") results in java.io.FileNotFoundException: ./config
  • .setGitDir(File("./.git") results in RepositoryNotFoundException: repository not found: ./.git though .git does exist. It is the file that points to the ../parent/.git/worktrees/test folder
  • .setGitDir(File("../parent/.git/worktrees/test") results in RepositoryNotFoundException: repository not found: ../parent/.git/worktrees/test
  • .setWorkTree(File(".") results in RepositoryNotFoundException: repository not found: ../parent/.git/worktrees/test which is interesting that it finds the path to the parent repository but can't open it?

Re: Can not open worktrees [message #1802530 is a reply to message #1802142] Mon, 11 February 2019 14:02 Go to previous messageGo to next message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 274
Registered: July 2009
Senior Member
It seems you have a very complicated setup of submodules and and worktrees. Are you aware of the "BUGS" section in native git's "git worktree" manpage:

Multiple checkout in general is still experimental, and the support for submodules is incomplete. It is NOT recommended to make multiple checkouts of a superproject.

Could it be you are doing exactly that .... multiple checkouts of a superproject?

Is there any public repository which you can share or steps how to reproduce your repository setup? I would like to clone and investigate.

But what I can see already now:
- You seem to be in a submodule because you don't have a .git folder but a .git file pointing to ../parent/.git/worktrees/test
- You seem to use multiple workspaces because the content of your .git file contains ....git/worktrees/...
- Typically the content of a .git file in a submodule directly after a native git recursive clone is like "gitdir: <relativePathToRootRepo>/.git/modules/<pathToSubmodule>. But youre .git file content is pointing to a <relativePathToRootRepo>/.git/worktrees/... folder? Strange. Maybe you have recursively cloned a root repo and then switched to multiple workspaces and then, in one of the workspaces you added a new submodule. Right?




Ciao
Chris
Re: Can not open worktrees [message #1802531 is a reply to message #1802530] Mon, 11 February 2019 14:13 Go to previous messageGo to next message
nice robot is currently offline nice robotFriend
Messages: 3
Registered: February 2019
Junior Member
Thanks for the reply.

I actually do not have a complicated setup and the repository does not have any submodules. This is all I do:

git clone REPOSITORY main
cd main
git worktree add BRANCH ../worktree

And I'm trying to access the worktree folder's git history.

I will create a demo repository in the coming days to show and demo the precise problem.

[Updated on: Mon, 11 February 2019 14:15]

Report message to a moderator

Re: Can not open worktrees [message #1802919 is a reply to message #1802530] Tue, 19 February 2019 03:40 Go to previous messageGo to next message
nice robot is currently offline nice robotFriend
Messages: 3
Registered: February 2019
Junior Member
This is almost certainly the same problem as submodules because worktrees use the same technique of a `.git` _file_ that points to the repository.

Here's the demo:

https://github.com/nicerobot/jgit-1802531

What are the plans to resolve this? It seems like an incredibly simple solution. If `.git` is a file, read its contents and open the repository to which it points.
Re: Can not open worktrees [message #1802967 is a reply to message #1802919] Tue, 19 February 2019 20:41 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
Andre started to implement worktree support for JGit
https://git.eclipse.org/r/#/q/project:jgit/jgit+is:open+message:worktree
feel free to help by implementing unit tests
Re: Can not open worktrees [message #1818125 is a reply to message #1802967] Fri, 06 December 2019 14:45 Go to previous message
Nicolas Albert is currently offline Nicolas AlbertFriend
Messages: 9
Registered: May 2017
Junior Member
Any news about this ?
Previous Topic:what is the of equivalent "git tag --points-at <commitId> in Jgit
Next Topic:Auto-create change-branch when pushing to gerrit
Goto Forum:
  


Current Time: Thu Apr 25 08:08:13 GMT 2024

Powered by FUDForum. Page generated in 0.03908 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top