Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cli/src/commands/git/colocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ pub struct GitColocationDisableArgs {}
/// Manage Jujutsu repository colocation with Git
#[derive(clap::Subcommand, Clone, Debug)]
pub enum GitColocationCommand {
Status(GitColocationStatusArgs),
Enable(GitColocationEnableArgs),
Disable(GitColocationDisableArgs),
Enable(GitColocationEnableArgs),
Status(GitColocationStatusArgs),
}

pub fn cmd_git_colocation(
Expand All @@ -63,9 +63,9 @@ pub fn cmd_git_colocation(
subcommand: &GitColocationCommand,
) -> Result<(), CommandError> {
match subcommand {
GitColocationCommand::Status(args) => cmd_git_colocation_status(ui, command, args),
GitColocationCommand::Enable(args) => cmd_git_colocation_enable(ui, command, args),
GitColocationCommand::Disable(args) => cmd_git_colocation_disable(ui, command, args),
GitColocationCommand::Enable(args) => cmd_git_colocation_enable(ui, command, args),
GitColocationCommand::Status(args) => cmd_git_colocation_status(ui, command, args),
}
}

Expand All @@ -79,9 +79,10 @@ fn repo_supports_git_colocation_commands(
git::get_git_backend(workspace_command.repo().store())?;

// Ensure that this is the main workspace
if workspace_command.repo_path().is_file() {
let repo_dir = workspace_command.workspace_root().join(".jj").join("repo");
if repo_dir.is_file() {
return Err(user_error(
"This command cannot be used in a non-main Jujutsu workspace.",
"This command cannot be used in a non-main Jujutsu workspace",
));
}
Ok(())
Expand Down
24 changes: 12 additions & 12 deletions cli/tests/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ This document contains the help content for the `jj` command-line program.
* [`jj git`↴](#jj-git)
* [`jj git clone`↴](#jj-git-clone)
* [`jj git colocation`↴](#jj-git-colocation)
* [`jj git colocation status`↴](#jj-git-colocation-status)
* [`jj git colocation enable`↴](#jj-git-colocation-enable)
* [`jj git colocation disable`↴](#jj-git-colocation-disable)
* [`jj git colocation enable`↴](#jj-git-colocation-enable)
* [`jj git colocation status`↴](#jj-git-colocation-status)
* [`jj git export`↴](#jj-git-export)
* [`jj git fetch`↴](#jj-git-fetch)
* [`jj git import`↴](#jj-git-import)
Expand Down Expand Up @@ -1351,17 +1351,19 @@ Manage Jujutsu repository colocation with Git

###### **Subcommands:**

* `status` — Show the current colocation status
* `enable` — Convert into a colocated Jujutsu/Git repository
* `disable` — Convert into a non-colocated Jujutsu/Git repository
* `enable` — Convert into a colocated Jujutsu/Git repository
* `status` — Show the current colocation status



## `jj git colocation status`
## `jj git colocation disable`

Show the current colocation status
Convert into a non-colocated Jujutsu/Git repository

**Usage:** `jj git colocation status`
This moves the Git repository that is at the root of the Jujutsu workspace into the .jj directory. Once this is done you will no longer be able to use Git commands directly in the Jujutsu workspace.

**Usage:** `jj git colocation disable`



Expand All @@ -1375,13 +1377,11 @@ This moves the underlying Git repository that is found inside the .jj directory



## `jj git colocation disable`

Convert into a non-colocated Jujutsu/Git repository
## `jj git colocation status`

This moves the Git repository that is at the root of the Jujutsu workspace into the .jj directory. Once this is done you will no longer be able to use Git commands directly in the Jujutsu workspace.
Show the current colocation status

**Usage:** `jj git colocation disable`
**Usage:** `jj git colocation status`



Expand Down
37 changes: 37 additions & 0 deletions cli/tests/test_git_colocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,40 @@ fn test_git_colocation_status_colocated() {
Hint: To disable colocation, run: `jj git colocation disable`
[EOF]");
}

#[test]
fn test_git_colocation_in_secondary_workspace() {
let test_env = TestEnvironment::default();
test_env
.run_jj_in(".", ["git", "init", "--no-colocate", "main"])
.success();
let main_dir = test_env.work_dir("main");
main_dir
.run_jj(["workspace", "add", "../secondary"])
.success();
let secondary_dir = test_env.work_dir("secondary");

let output = secondary_dir.run_jj(["git", "colocation", "status"]);
insta::assert_snapshot!(output, @r"
------- stderr -------
Error: This command cannot be used in a non-main Jujutsu workspace
[EOF]
[exit status: 1]
");

let output = secondary_dir.run_jj(["git", "colocation", "enable"]);
insta::assert_snapshot!(output, @r"
------- stderr -------
Error: This command cannot be used in a non-main Jujutsu workspace
[EOF]
[exit status: 1]
");

let output = secondary_dir.run_jj(["git", "colocation", "disable"]);
insta::assert_snapshot!(output, @r"
------- stderr -------
Error: This command cannot be used in a non-main Jujutsu workspace
[EOF]
[exit status: 1]
");
}