Support "bare" repo workflow with jujutsu#164
Merged
junglerobba merged 3 commits intojrmoulton:mainfrom Jun 24, 2025
Merged
Conversation
Collaborator
Author
|
Note, apparently non-colocated repos are always considered bare with the current logic, so the check for that is not correct yet. I guess in that case jj does not care about the git head at all? Need to find something better for that. |
Collaborator
Author
|
This should work correctly now, regardless whether the repo is co-located or not |
jrmoulton
approved these changes
Jun 16, 2025
jj doesn't directly support bare repos, but a repo where the root commit is checked out can be considered bare. Workspaces can then also be initialized inside the main repo directory, though it's a good idea to add a .gitignore ignoring everything (*) in that case, otherwise running jj commands will snapshot files in all workspaces.
Because jj doesn't keep references to workspaces anywhere (they only link back to the main repo by .jj/repo simply pointing to where the main repo is), we need a special case for a "bare" jj repo with workspaces checked out inside of its own directory. Because we usually stop searching for repos once we've hit one, when searching for workspaces of bare jj repos, check all directories inside of the repo directory as well (with depth 1 only for now, even though this could technically go deeper?)
* refactors worktree creation to RepoProvider * uses subprocess same as git, currently the main usage of jj-lib is with ReadonlyRepo, butmaybe this can be changed at some point, since jj-lib does in fact have all of the functionality
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
jj doesn't directly support bare repos, but a repo where the root commit
is checked out (
jj new -r 'root()') can be considered very similar. Workspaces can then alsobe initialized inside the main repo directory, though it's good idea to
add a
.gitignoreignoring everything (*) in that case, otherwise runningjj commands will snapshot files in all workspaces.
A small (but probably negligible) side effect of this is, if after just initializing a new jj repo, it is still on the root commit, so opening it with tms will initialize the default "trunk" workspace. This will no longer happen once any other commits are checked out.