-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jj git colocate
#4833
base: main
Are you sure you want to change the base?
jj git colocate
#4833
Conversation
16ec8cb
to
6091659
Compare
Would it be |
14df9e7
to
c5ad1b8
Compare
|
If you're turning off git, you are really turning a page on what once was. One might type it with a renewed sense of purpose, confidence in your knowledge of the JJ way, and independence of the crutch you once needed. In that vein I suggest
(Also like |
|
|
|
c5ad1b8
to
e9de61d
Compare
We need this to differentiate primary/secondary workspaces when choosing how to colocate them (and for now, doing nothing for workspaces as worktrees have not landed).
c510233
to
335ac54
Compare
I really like If there must be a command under fwiw ;-) |
cli/src/commands/git/colocate.rs
Outdated
let old_path = workspace_command.repo_path().join("store").join("git"); | ||
let new_path = workspace.workspace_root().join(".git"); | ||
fs::rename(&old_path, &new_path).context(old_path)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, we have to check that old_path exists (and is a directory, and is not a symlink, and also that git_target points to it) before we commit to writing out core.bare=false.
As long as we check this, I don't think we need to handle the large variety of git_target scenarios outside of this, because there will soon be an alternative, which is to just add a worktree. Which will work in many more scenarios. git_target can point into outer space for all we care.
The idea is to have --prefer-worktree
switch to using worktrees in the primary workspace, as well as secondary ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
60c3272
to
db0a1eb
Compare
Initially, we can only colocate the primary workspace. See <https://martinvonz.github.io/jj/latest/git-compatibility/#converting-a-repo-into-a-co-located-repo> for the steps. Adds a Workspace::reload() function to reload the workspace from the file system, which is technically not necessary for this diff, but will become necessary soon, when we make the GitBackend colocation-aware.
db0a1eb
to
5fb6856
Compare
I'd like to have the inverse in the native backend with something like |
} | ||
|
||
let git_repo = git_backend.git_repo(); | ||
if workspace.is_primary_workspace() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we detect this somehow by caller or git layer?
I don't think "is primary workspace" can be a common concept across working-copy/workspace-loader backends.
|
||
if workspace_command.working_copy_shared_with_git() { | ||
return Err(user_error(format!( | ||
"Workspace '{}' is already colocated.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: error message doesn't usually contain period
let old_path_canon = old_path.canonicalize().ok(); | ||
|
||
let mut config = | ||
gix::config::File::from_git_dir(common_dir.to_path_buf()).map_err(internal_error)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe this should be a user error (assuming it would do some I/O)?
BTW, the gix' fetch/clone implementation might help understand their config API. I'm not familiar with that.
https://github.com/GitoxideLabs/gitoxide/blob/main/gix/src/clone/fetch/util.rs
// | ||
// This way we end up with a git HEAD written immediately, rather than | ||
// next time @ moves. And you can immediately start running git commands. | ||
let workspace = workspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use command.workspace_helper_no_snapshot()
?
|
||
git::reset_head(tx.repo_mut(), &git2_repo, &wc_commit)?; | ||
|
||
tx.finish(ui, format!("Colocated existing workspace {name}"))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Colocated
-> colocate
if old_path.is_symlink() | ||
|| !old_path.is_dir() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use .symlink_metadata()
instead of stat()
ing twice?
I don't like the name |
Fixes #4624
Open to bikesheds on what to call the inverse command.
jj git delocate
?Checklist
If applicable:
CHANGELOG.md