Skip to content

Commit

Permalink
cli: rename --colocated flag of "jj git init" to --colocate (verb)
Browse files Browse the repository at this point in the history
"jj git clone" has --colocate flag, so let's stick to it.

jj-vcs#2747
  • Loading branch information
yuja committed Feb 7, 2024
1 parent 1be8225 commit 2792459
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions cli/src/commands/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub struct GitInitArgs {
///
/// This option is mutually exclusive with `--git-repo`.
#[arg(long, conflicts_with = "git_repo")]
colocated: bool,
colocate: bool,

/// Specifies a path to an **existing** git repository to be
/// used as the backing git repo for the newly created `jj` repo.
Expand All @@ -146,10 +146,10 @@ pub struct GitInitArgs {
/// will not be auto-exported to the git repo.
///
/// Auto-exporting from `jj` to `git` is only enabled for new repos.
/// See `--colocated` above.
/// See `--colocate` above.
///
/// This option is mutually exclusive with `--colocated`.
#[arg(long, conflicts_with = "colocated", value_hint = clap::ValueHint::DirPath)]
/// This option is mutually exclusive with `--colocate`.
#[arg(long, conflicts_with = "colocate", value_hint = clap::ValueHint::DirPath)]
git_repo: Option<String>,
}

Expand Down Expand Up @@ -374,13 +374,13 @@ pub fn git_init(
ui: &mut Ui,
command: &CommandHelper,
workspace_root: &Path,
colocated: bool,
colocate: bool,
git_repo: Option<&str>,
) -> Result<(), CommandError> {
let cwd = command.cwd().canonicalize().unwrap();
let relative_wc_path = file_util::relative_path(&cwd, workspace_root);

if colocated {
if colocate {
let (workspace, repo) = Workspace::init_colocated_git(command.settings(), workspace_root)?;
let workspace_command = command.for_loaded_repo(ui, workspace, repo)?;
maybe_add_gitignore(&workspace_command)?;
Expand Down Expand Up @@ -481,7 +481,7 @@ fn cmd_git_init(
ui,
command,
&wc_path,
args.colocated,
args.colocate,
args.git_repo.as_deref(),
)?;

Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ pub(crate) fn cmd_init(

// Preserve existing behaviour where `jj init` is not able to create
// a colocated repo.
let colocated = false;
let colocate = false;
if args.git || args.git_repo.is_some() {
git::git_init(ui, command, &wc_path, colocated, args.git_repo.as_deref())?;
git::git_init(ui, command, &wc_path, colocate, args.git_repo.as_deref())?;
writeln!(
ui.warning(),
"warning: `--git` and `--git-repo` are deprecated.
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ Create a new Git backed repo
###### **Options:**
* `--colocated` — Specifies that the `jj` repo should also be a valid `git` repo, allowing the use of both `jj` and `git` commands in the same directory
* `--colocate` — Specifies that the `jj` repo should also be a valid `git` repo, allowing the use of both `jj` and `git` commands in the same directory
Possible values: `true`, `false`
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/test_git_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ fn test_git_init_colocated_via_flag_git_dir_exists() {
let workspace_root = test_env.env_root().join("repo");
init_git_repo(&workspace_root, false);

let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "init", "--colocated"]);
let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "init", "--colocate"]);
insta::assert_snapshot!(stderr, @r###"
Error: Failed to access the repository
Caused by:
Expand All @@ -555,7 +555,7 @@ fn test_git_init_colocated_via_flag_git_dir_exists() {
fn test_git_init_colocated_via_flag_git_dir_not_exists() {
let test_env = TestEnvironment::default();
let (stdout, stderr) =
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "--colocated", "repo"]);
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "--colocate", "repo"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Initialized repo in "repo"
Expand Down

0 comments on commit 2792459

Please sign in to comment.