Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Plug for multiple worktree support

Just wanted to put in a plug for the great patches by Andre Bossert which provide support for git-worktree.

He first submitted this as one large change in Mar 2016, and worked through feedback all the way to Dec 2017: https://git.eclipse.org/r/#/c/67873/  He reworked as a few small changes, and submitted in Jul 2018.  And they've just been rebased on top of master as of today, June 1st 2020.  In the original patchset in 2016, it was necessary to touch 13 files.  Today, in 2020, it is necessary to touch 33 files.

In order to support multiple worktrees, the first big change is a simple code cleanup, which replaces magic strings throughout the code with proper constants.

The second big change replaces manual file manipulation with a cleaner `Repository.getDirectoyChild()`

So the first two patchsets add no functionality, they just do cleanup which is helpful even without worktree support.  Unfortunately, they touch lots of files, so they cause merge conflicts very quickly.  But once they have been merged, it makes worktree much easier to add, and it will make all the rest of jgit cleaner as well.  Both of the patches above have already passed CI.

The third change which adds read support for git-worktree is a bit more complicated, but much easier to work on because it doesn't touch so many files.  It is currently failing on CI, and I'm investigating on my local machine.

If the first two changes can be reviewed and merged quickly, I think it would make the whole codebase better (fewer magic constants, less manual filesystem manipulation), and it will help massively with the merge conflicts that make multiple worktree support so hard to merge in.

I've always wanted to be able to do `git bisect` without changing my current checkout.  Worktree makes it possible to use jgit to make handy tools like this, that operate on efficient temporary checkouts.  It would also fix a whole class of bugs for build tools that use JGit, but don't work if the user is using worktree: https://github.com/diffplug/spotless/issues/75. The cc list for the bugzilla "Add worktree support" has 69 watchers, which indicates broad interest in this feature: https://bugs.eclipse.org/bugs/show_bug.cgi?id=477475

Ned Twigg
Lead Software Architect, DiffPlug LLC
540-336-8043 (cell)
888-513-6870 (fax)
340 S Lemon Ave #343
3, Walnut, CA 91789

Back to the top