Skip to content

Support "bare" repo workflow with jujutsu#164

Merged
junglerobba merged 3 commits intojrmoulton:mainfrom
junglerobba:jj-bare
Jun 24, 2025
Merged

Support "bare" repo workflow with jujutsu#164
junglerobba merged 3 commits intojrmoulton:mainfrom
junglerobba:jj-bare

Conversation

@junglerobba
Copy link
Collaborator

@junglerobba junglerobba commented Jun 11, 2025

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 also
be initialized inside the main repo directory, though it's good idea to
add a .gitignore ignoring everything (*) in that case, otherwise running
jj 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.

@junglerobba junglerobba marked this pull request as draft June 11, 2025 21:59
@junglerobba
Copy link
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.

@junglerobba junglerobba marked this pull request as ready for review June 13, 2025 23:11
@junglerobba
Copy link
Collaborator Author

This should work correctly now, regardless whether the repo is co-located or not

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
@junglerobba junglerobba merged commit ce41723 into jrmoulton:main Jun 24, 2025
6 checks passed
@junglerobba junglerobba deleted the jj-bare branch June 24, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants