From b0a6493d20221557e536cc189d6784c1999d5695 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 2 Feb 2023 15:11:18 -0800 Subject: [PATCH] cli: rename `--no-commit-working-copy` to `--ignore-working-copy` We have moved from saying "committing the working copy" towards saying "snapshotting the working copy". More importantly, the option also means that we don't update the working copy at the end. I went with the `--ignore-working-copy` name suggested by Ilya. I also updated the documentation of the option. --- CHANGELOG.md | 2 ++ src/cli_util.rs | 26 +++++++++++++++----------- tests/test_edit_command.rs | 4 ++-- tests/test_global_opts.rs | 10 +++++----- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1774da178..685b50e62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Use `if(description, description, "(no description set)\n")` to get back the previous behavior. +* The global `--no-commit-working-copy` is now called `--ignore-working-copy`. + ### New features * The default log format now uses the committer timestamp instead of the author diff --git a/src/cli_util.rs b/src/cli_util.rs index 30a5c55c3..01c6a50dc 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -465,7 +465,7 @@ impl WorkspaceCommandHelper { ) -> Result { let revset_aliases_map = load_revset_aliases(ui, &settings)?; let loaded_at_head = &global_args.at_operation == "@"; - let may_update_working_copy = loaded_at_head && !global_args.no_commit_working_copy; + let may_update_working_copy = loaded_at_head && !global_args.ignore_working_copy; let mut working_copy_shared_with_git = false; let maybe_git_repo = repo.store().git_repo(); if let Some(git_workdir) = maybe_git_repo @@ -492,8 +492,8 @@ impl WorkspaceCommandHelper { if self.may_update_working_copy { Ok(()) } else { - let hint = if self.global_args.no_commit_working_copy { - "Don't use --no-commit-working-copy." + let hint = if self.global_args.ignore_working_copy { + "Don't use --ignore-working-copy." } else { "Don't use --at-op." }; @@ -1574,16 +1574,20 @@ pub struct GlobalArgs { value_hint = clap::ValueHint::DirPath, )] pub repository: Option, - /// Don't commit the working copy + /// Don't snapshot the working copy, and don't update it /// - /// By default, Jujutsu commits the working copy on every command, unless - /// you load the repo at a specific operation with `--at-operation`. If - /// you want to avoid committing the working and instead see a possibly - /// stale working copy commit, you can use `--no-commit-working-copy`. + /// By default, Jujutsu snapshots the working copy at the beginning of every + /// command. The working copy is also updated at the end of the command, + /// if the command modified the working-copy commit (`@`). If you want + /// to avoid snapshotting the working and instead see a possibly + /// stale working copy commit, you can use `--ignore-working-copy`. /// This may be useful e.g. in a command prompt, especially if you have /// another process that commits the working copy. + /// + /// Loading the repository is at a specific operation with `--at-operation` + /// implies `--ignore-working-copy`. #[arg(long, global = true, help_heading = "Global Options")] - pub no_commit_working_copy: bool, + pub ignore_working_copy: bool, /// Operation to load the repo at /// /// Operation to load the repo at. By default, Jujutsu loads the repo at the @@ -1595,8 +1599,8 @@ pub struct GlobalArgs { /// Use `jj op log` to find the operation ID you want. Any unambiguous /// prefix of the operation ID is enough. /// - /// When loading the repo at an earlier operation, the working copy will not - /// be automatically committed. + /// When loading the repo at an earlier operation, the working copy will be + /// ignored, as if `--ignore-working-copy` had been specified. /// /// It is possible to run mutating commands when loading the repo at an /// earlier operation. Doing that is equivalent to having run concurrent diff --git a/tests/test_edit_command.rs b/tests/test_edit_command.rs index 5d0f8b3df..8c8143753 100644 --- a/tests/test_edit_command.rs +++ b/tests/test_edit_command.rs @@ -91,11 +91,11 @@ fn test_edit_current_wc_commit_missing() { .join("542c1984c1f9d91f7c6c9c9e6941782c944bd9"); std::fs::remove_file(commit_object_path).unwrap(); - // Pass --no-commit-working-copy to avoid triggering the error at snapshot time + // Pass --ignore-working-copy to avoid triggering the error at snapshot time let assert = test_env .jj_cmd( &repo_path, - &["edit", "--no-commit-working-copy", "5c52832c3483"], + &["edit", "--ignore-working-copy", "5c52832c3483"], ) .assert() .code(255); diff --git a/tests/test_global_opts.rs b/tests/test_global_opts.rs index ef6ff70f0..e772f5c4d 100644 --- a/tests/test_global_opts.rs +++ b/tests/test_global_opts.rs @@ -62,7 +62,7 @@ fn test_no_subcommand() { } #[test] -fn test_no_commit_working_copy() { +fn test_ignore_working_copy() { let test_env = TestEnvironment::default(); test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]); @@ -75,16 +75,16 @@ fn test_no_commit_working_copy() { o 0000000000000000000000000000000000000000 "###); - // Modify the file. With --no-commit-working-copy, we still get the same commit + // Modify the file. With --ignore-working-copy, we still get the same commit // ID. std::fs::write(repo_path.join("file"), "modified").unwrap(); let stdout_again = test_env.jj_cmd_success( &repo_path, - &["log", "-T", "commit_id", "--no-commit-working-copy"], + &["log", "-T", "commit_id", "--ignore-working-copy"], ); assert_eq!(stdout_again, stdout); - // But without --no-commit-working-copy, we get a new commit ID. + // But without --ignore-working-copy, we get a new commit ID. let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-T", "commit_id"]); insta::assert_snapshot!(stdout, @r###" @ fab22d1acf5bb9c5aa48cb2c3dd2132072a359ca @@ -346,7 +346,7 @@ fn test_help() { Global Options: -R, --repository Path to repository to operate on - --no-commit-working-copy Don't commit the working copy + --ignore-working-copy Don't snapshot the working copy, and don't update it --at-operation Operation to load the repo at [default: @] [aliases: at-op] -v, --verbose Enable verbose logging --color When to colorize output (always, never, auto)