diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index a1b322b239..5c32dad31f 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -2975,8 +2975,10 @@ impl CliRunner { } let maybe_workspace_loader = if let Some(path) = &args.global_args.repository { - WorkspaceLoader::init(&cwd.join(path)) - .map_err(|err| map_workspace_load_error(err, Some(path))) + // Invalid -R path is an error. No need to proceed. + let loader = WorkspaceLoader::init(&cwd.join(path)) + .map_err(|err| map_workspace_load_error(err, Some(path)))?; + Ok(loader) } else { WorkspaceLoader::init(find_workspace_dir(&cwd)) .map_err(|err| map_workspace_load_error(err, None)) diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index bb8912265c..bb16ab611b 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -442,9 +442,6 @@ fn cmd_git_clone( command: &CommandHelper, args: &GitCloneArgs, ) -> Result<(), CommandError> { - if command.global_args().repository.is_some() { - return Err(user_error("'--repository' cannot be used with 'git clone'")); - } let remote_name = "origin"; let source = absolute_git_source(command.cwd(), &args.source); let wc_path_str = args diff --git a/cli/src/commands/init.rs b/cli/src/commands/init.rs index d13fca6449..b261903c24 100644 --- a/cli/src/commands/init.rs +++ b/cli/src/commands/init.rs @@ -53,9 +53,6 @@ pub(crate) fn cmd_init( command: &CommandHelper, args: &InitArgs, ) -> Result<(), CommandError> { - if command.global_args().repository.is_some() { - return Err(user_error("'--repository' cannot be used with 'init'")); - } let wc_path = command.cwd().join(&args.destination); match fs::create_dir(&wc_path) { Ok(()) => {} diff --git a/cli/tests/test_global_opts.rs b/cli/tests/test_global_opts.rs index 08b85b17bf..93f01f3f1a 100644 --- a/cli/tests/test_global_opts.rs +++ b/cli/tests/test_global_opts.rs @@ -133,7 +133,7 @@ fn test_repo_arg_with_init() { let test_env = TestEnvironment::default(); let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["init", "-R=.", "repo"]); insta::assert_snapshot!(stderr, @r###" - Error: '--repository' cannot be used with 'init' + Error: There is no jj repo in "." "###); } @@ -142,7 +142,7 @@ fn test_repo_arg_with_git_clone() { let test_env = TestEnvironment::default(); let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["git", "clone", "-R=.", "remote"]); insta::assert_snapshot!(stderr, @r###" - Error: '--repository' cannot be used with 'git clone' + Error: There is no jj repo in "." "###); }