workspace add/forget: bridge jj workspaces with git worktrees - #9941
workspace add/forget: bridge jj workspaces with git worktrees#9941calebdw wants to merge 1 commit into
Conversation
6321713 to
8a15bee
Compare
8a15bee to
8072db9
Compare
8072db9 to
5cbe6bd
Compare
5cbe6bd to
abd5547
Compare
d6fdce3 to
4b96a0b
Compare
4b96a0b to
15e5876
Compare
15e5876 to
00c2e61
Compare
Not sure I see the why worktrees should not be colocated if the main repo is---I considered adding options to disable it, but figured that's just pointless. By virtue of being in a colocated repo there's no real reason why the worktrees should not also be colocated with the workspaces---of course in a non-colocated repo this doesn't matter (and it goes without saying that you should not be able to colocate a workspace if the main workspace is also not colocated)
I didn't check before I started working on this (I suppose I should have), I can close out the rest of my PRs if there's better minds than mine already working on this. My first PR was just merged and lays the groundwork for the worktree colocation work by tracking HEAD per worktree (there was an existing TODO in the code to do this anyway) cc: @sjawhar |
I mean have
I would keep it open because it'll hopefully force the maintainers to finally reconcile on the situation. |
If the main jj repository is not colocated with a git repository, then how do you expect to colocate a child workspace? My point is the "opt-in" is whether or not the repository is colocated---there shouldn't be a separate option to colocate worktrees/workspaces but not the main repository (which technically are a worktree/workspace in and of themselves) |
By working with the bare repo within
I disagree, since you should be able to opt-in, and its also something we already discussed on Discord (I suggest you to look at the surrounding discussion). |
+1
I'm open to adding a simpler version of these PRs. IIRC, my main concern with #4644/#4588 was that it was too big and included unnecessary changes. I'm not sure if its successor, #8867, addressed these issues. I'm also not sure if the author of #8867 understands its design and implementation. |
In what terms do you mean simpler? #8667 now only contains the
While this is a fair opinion to have, I don't think it should block work on which so many people are waiting on. Otherwise its something you should discuss on our AI policy issue (#9219) since that just relates to the author and his tool usage. |
For instance, it would be nice if we could get rid of "workspace: Make backend factories aware of the workspace root". This PR doesn't seem to have that one. (I'm not sure if we can avoid it for the foreseeable future, but it's a controversial change.)
I personally don't want to spend my time repeatedly reviewing patches revived without an understanding of what the original problem was. I understand that this is an important feature, so I'm reviewing this PR stack. |
00c2e61 to
8e9da77
Compare
|
@yuja, @PhilipMetzger, I've added |
2cdec3a to
0d5879a
Compare
OK, this is a fair point although you probably did find it OK two years ago? This set of PRs is vastly simpler exactly because it doesn't try to wire itself to all the
OK, thanks for clarifying this and since that is a personal opinion it would've been nice to have on the PR since its clearly better than saying nothing for 1,5 years. |
7f6439c to
2bcdb68
Compare
a1153a1 to
eaacf53
Compare
8a14b3f to
dfd3b9b
Compare
dfd3b9b to
ec11451
Compare
ec11451 to
2a4c46e
Compare
2a4c46e to
712b325
Compare
`jj workspace add` now supports `--colocate`/`--no-colocate` flags to control whether a corresponding Git worktree is created alongside the jj workspace. By default, a worktree is created when the current workspace is colocated and the `git.colocate` config is `true`. If Git HEAD does not yet point to a commit (freshly initialized repo with no commits), workspace add errors rather than silently falling back to a non-colocated workspace. This is a Git limitation: `git worktree add` requires a valid HEAD reference. `jj workspace forget` removes the corresponding Git worktree when one exists by deleting the `.git` gitlink file and pruning the worktree metadata, preserving the workspace directory contents.
712b325 to
8c87d87
Compare
jj workspace addnow supports--colocate/--no-colocateflags to control whether a corresponding Git worktree is created alongside the jj workspace. By default, a worktree is created when the current workspace is colocated and thegit.colocateconfig istrue.If Git HEAD does not yet point to a commit (freshly initialized repo with no commits),
workspace adderrors rather than silently falling back to a non-colocated workspace. This is a Git limitation:git worktree addrequires a valid HEAD reference.jj workspace forgetremoves the corresponding Git worktree when one exists by deleting the.gitgitlink file and pruning the worktree metadata, preserving the workspace directory contents.The git worktree is created before the jj workspace is initialized, so the directory structure contains both
.git(gitlink to the worktree) and.jj/(pointing back to the shared repo store). Git worktrees are created with relative paths to match jj's convention for portable repositories.For non-colocated repos, behavior is unchanged.
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)how it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.