ok/jj
1
0
Fork 0
forked from mirrors/jj

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.
This commit is contained in:
Martin von Zweigbergk 2023-02-02 15:11:18 -08:00 committed by Martin von Zweigbergk
parent 45a018ec6b
commit b0a6493d20
4 changed files with 24 additions and 18 deletions

View file

@ -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

View file

@ -465,7 +465,7 @@ impl WorkspaceCommandHelper {
) -> Result<Self, CommandError> {
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<String>,
/// 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

View file

@ -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);

View file

@ -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 <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 <AT_OPERATION> Operation to load the repo at [default: @] [aliases: at-op]
-v, --verbose Enable verbose logging
--color <WHEN> When to colorize output (always, never, auto)