// Copyright 2022 The Jujutsu Authors//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at//// https://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License. use crate::common::TestEnvironment;use crate::common::to_toml_value; #[test]fn test_log_with_empty_revision() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-r="]); insta::assert_snapshot!(output, @r" ------- stderr ------- error: a value is required for '--revisions <REVSETS>' but none was supplied For more information, try '--help'. [EOF] [exit status: 2] ");} #[test]fn test_log_with_no_template() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-T"]); insta::assert_snapshot!(output, @r" ------- stderr ------- error: a value is required for '--template <TEMPLATE>' but none was supplied For more information, try '--help'. Hint: The following template aliases are defined: - builtin_config_list - builtin_config_list_detailed - builtin_draft_commit_description - builtin_log_comfortable - builtin_log_compact - builtin_log_compact_full_description - builtin_log_detailed - builtin_log_node - builtin_log_node_ascii - builtin_log_oneline - builtin_op_log_comfortable - builtin_op_log_compact - builtin_op_log_node - builtin_op_log_node_ascii - builtin_op_log_oneline - commit_summary_separator - default_commit_description - description_placeholder - email_placeholder - git_format_patch_email_headers - name_placeholder [EOF] [exit status: 2] ");} #[test]fn test_log_with_or_without_diff() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.write_file("file1", "foo\n"); work_dir.run_jj(["describe", "-m", "add a file"]).success(); work_dir.run_jj(["new", "-m", "a new commit"]).success(); work_dir.write_file("file1", "foo\nbar\n"); let output = work_dir.run_jj(["log", "-T", "description"]); insta::assert_snapshot!(output, @r" @ a new commit ○ add a file ◆ [EOF] "); let output = work_dir.run_jj(["log", "-T", "description", "-p"]); insta::assert_snapshot!(output, @r" @ a new commit │ Modified regular file file1: │ 1 1: foo │ 2: bar ○ add a file │ Added regular file file1: │ 1: foo ◆ [EOF] "); let output = work_dir.run_jj(["log", "-T", "description", "--no-graph"]); insta::assert_snapshot!(output, @r" a new commit add a file [EOF] "); // `-p` for default diff output, `-s` for summary let output = work_dir.run_jj(["log", "-T", "description", "-p", "-s"]); insta::assert_snapshot!(output, @r" @ a new commit │ M file1 │ Modified regular file file1: │ 1 1: foo │ 2: bar ○ add a file │ A file1 │ Added regular file file1: │ 1: foo ◆ [EOF] "); // `-s` for summary, `--git` for git diff (which implies `-p`) let output = work_dir.run_jj(["log", "-T", "description", "-s", "--git"]); insta::assert_snapshot!(output, @r" @ a new commit │ M file1 │ diff --git a/file1 b/file1 │ index 257cc5642c..3bd1f0e297 100644 │ --- a/file1 │ +++ b/file1 │ @@ -1,1 +1,2 @@ │ foo │ +bar ○ add a file │ A file1 │ diff --git a/file1 b/file1 │ new file mode 100644 │ index 0000000000..257cc5642c │ --- /dev/null │ +++ b/file1 │ @@ -0,0 +1,1 @@ │ +foo ◆ [EOF] "); // `-p` for default diff output, `--stat` for diff-stat let output = work_dir.run_jj(["log", "-T", "description", "-p", "--stat"]); insta::assert_snapshot!(output, @r" @ a new commit │ file1 | 1 + │ 1 file changed, 1 insertion(+), 0 deletions(-) │ Modified regular file file1: │ 1 1: foo │ 2: bar ○ add a file │ file1 | 1 + │ 1 file changed, 1 insertion(+), 0 deletions(-) │ Added regular file file1: │ 1: foo ◆ 0 files changed, 0 insertions(+), 0 deletions(-) [EOF] "); // `--stat` is short format, which should be printed first let output = work_dir.run_jj(["log", "-T", "description", "--git", "--stat"]); insta::assert_snapshot!(output, @r" @ a new commit │ file1 | 1 + │ 1 file changed, 1 insertion(+), 0 deletions(-) │ diff --git a/file1 b/file1 │ index 257cc5642c..3bd1f0e297 100644 │ --- a/file1 │ +++ b/file1 │ @@ -1,1 +1,2 @@ │ foo │ +bar ○ add a file │ file1 | 1 + │ 1 file changed, 1 insertion(+), 0 deletions(-) │ diff --git a/file1 b/file1 │ new file mode 100644 │ index 0000000000..257cc5642c │ --- /dev/null │ +++ b/file1 │ @@ -0,0 +1,1 @@ │ +foo ◆ 0 files changed, 0 insertions(+), 0 deletions(-) [EOF] "); // `-p` enables default "summary" output, so `-s` is noop let output = work_dir.run_jj([ "log", "-T", "description", "-p", "-s", "--config=ui.diff-formatter=:summary", ]); insta::assert_snapshot!(output, @r" @ a new commit │ M file1 ○ add a file │ A file1 ◆ [EOF] "); // `-p` enables default "color-words" diff output, so `--color-words` is noop let output = work_dir.run_jj(["log", "-T", "description", "-p", "--color-words"]); insta::assert_snapshot!(output, @r" @ a new commit │ Modified regular file file1: │ 1 1: foo │ 2: bar ○ add a file │ Added regular file file1: │ 1: foo ◆ [EOF] "); // `--git` enables git diff, so `-p` is noop let output = work_dir.run_jj(["log", "-T", "description", "--no-graph", "-p", "--git"]); insta::assert_snapshot!(output, @r" a new commit diff --git a/file1 b/file1 index 257cc5642c..3bd1f0e297 100644 --- a/file1 +++ b/file1 @@ -1,1 +1,2 @@ foo +bar add a file diff --git a/file1 b/file1 new file mode 100644 index 0000000000..257cc5642c --- /dev/null +++ b/file1 @@ -0,0 +1,1 @@ +foo [EOF] "); // Cannot use both `--git` and `--color-words` let output = work_dir.run_jj([ "log", "-T", "description", "--no-graph", "-p", "--git", "--color-words", ]); insta::assert_snapshot!(output, @r" ------- stderr ------- error: the argument '--git' cannot be used with '--color-words' Usage: jj log --template <TEMPLATE> --no-graph --patch --git [FILESETS]... For more information, try '--help'. [EOF] [exit status: 2] "); // `-s` with or without graph let output = work_dir.run_jj(["log", "-T", "description", "-s"]); insta::assert_snapshot!(output, @r" @ a new commit │ M file1 ○ add a file │ A file1 ◆ [EOF] "); let output = work_dir.run_jj(["log", "-T", "description", "--no-graph", "-s"]); insta::assert_snapshot!(output, @r" a new commit M file1 add a file A file1 [EOF] "); // `--git` implies `-p`, with or without graph let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--git"]); insta::assert_snapshot!(output, @r" @ a new commit │ diff --git a/file1 b/file1 ~ index 257cc5642c..3bd1f0e297 100644 --- a/file1 +++ b/file1 @@ -1,1 +1,2 @@ foo +bar [EOF] "); let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--no-graph", "--git"]); insta::assert_snapshot!(output, @r" a new commit diff --git a/file1 b/file1 index 257cc5642c..3bd1f0e297 100644 --- a/file1 +++ b/file1 @@ -1,1 +1,2 @@ foo +bar [EOF] "); // `--color-words` implies `-p`, with or without graph let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--color-words"]); insta::assert_snapshot!(output, @r" @ a new commit │ Modified regular file file1: ~ 1 1: foo 2: bar [EOF] "); let output = work_dir.run_jj([ "log", "-T", "description", "-r", "@", "--no-graph", "--color-words", ]); insta::assert_snapshot!(output, @r" a new commit Modified regular file file1: 1 1: foo 2: bar [EOF] ");} #[test]fn test_log_null_terminate_multiline_descriptions() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir .run_jj(["commit", "-m", "commit 1 line 1", "-m", "commit 1 line 2"]) .success(); work_dir .run_jj(["commit", "-m", "commit 2 line 1", "-m", "commit 2 line 2"]) .success(); work_dir .run_jj(["describe", "-m", "commit 3 line 1", "-m", "commit 3 line 2"]) .success(); let output = work_dir .run_jj([ "log", "-r", "~root()", "-T", r#"description ++ "\0""#, "--no-graph", ]) .success(); insta::assert_debug_snapshot!( output.stdout.normalized(), @r#""commit 3 line 1\n\ncommit 3 line 2\n\0commit 2 line 1\n\ncommit 2 line 2\n\0commit 1 line 1\n\ncommit 1 line 2\n\0""# );} #[test]fn test_log_shortest_accessors() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let render = |rev, template| work_dir.run_jj(["log", "--no-graph", "-r", rev, "-T", template]); test_env.add_config( r#" [template-aliases] 'format_id(id)' = 'id.shortest(12).prefix() ++ "[" ++ id.shortest(12).rest() ++ "]"' "#, ); work_dir.write_file("file", "original file\n"); work_dir.run_jj(["describe", "-m", "initial"]).success(); work_dir .run_jj(["bookmark", "c", "-r@", "original"]) .success(); insta::assert_snapshot!( render("original", r#"format_id(change_id) ++ " " ++ format_id(commit_id)"#), @"q[pvuntsmwlqt] 8[216f646c36d][EOF]"); // Create a chain of 10 commits for i in 1..10 { work_dir .run_jj(["new", "-m", &format!("commit{i}")]) .success(); work_dir.write_file("file", format!("file {i}\n")); } // Create 2^3 duplicates of the chain for _ in 0..3 { work_dir .run_jj(["duplicate", "description(commit)"]) .success(); } insta::assert_snapshot!( render("original", r#"format_id(change_id) ++ " " ++ format_id(commit_id)"#), @"qpv[untsmwlqt] 82[16f646c36d][EOF]"); insta::assert_snapshot!( render("::@", r#"change_id.shortest() ++ " " ++ commit_id.shortest() ++ "\n""#), @r" wq c2 km 74 kp 97 zn 78 yo 40 vr bc9 yq 28 ro af mz 04 qpv 82 zzz 00 [EOF] "); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" wq[nwkozpkust] c2[b4c0bb3362] km[kuslswpqwq] 74[fcd50c0643] kp[qxywonksrl] 97[dcaada9b8d] zn[kkpsqqskkl] 78[c03ab2235b] yo[stqsxwqrlt] 40[1119280761] vr[uxwmqvtpmx] bc9[e8942b459] yq[osqzytrlsw] 28[edbc9658ef] ro[yxmykxtrkr] af[3e6a27a1d0] mz[vwutvlkqwt] 04[6c6a1df762] qpv[untsmwlqt] 82[16f646c36d] zzz[zzzzzzzzz] 00[0000000000] [EOF] "); // Can get shorter prefixes in configured revset test_env.add_config(r#"revsets.short-prefixes = "(@----)::""#); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" w[qnwkozpkust] c[2b4c0bb3362] km[kuslswpqwq] 74[fcd50c0643] kp[qxywonksrl] 9[7dcaada9b8d] z[nkkpsqqskkl] 78[c03ab2235b] y[ostqsxwqrlt] 4[01119280761] vr[uxwmqvtpmx] bc9[e8942b459] yq[osqzytrlsw] 28[edbc9658ef] ro[yxmykxtrkr] af[3e6a27a1d0] mz[vwutvlkqwt] 04[6c6a1df762] qpv[untsmwlqt] 82[16f646c36d] zzz[zzzzzzzzz] 00[0000000000] [EOF] "); // Can disable short prefixes by setting to empty string test_env.add_config(r#"revsets.short-prefixes = """#); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" wq[nwkozpkust] c2[b4c0bb3362] km[kuslswpqwq] 74[fcd50c0643] kp[qxywonksrl] 97[dcaada9b8d] zn[kkpsqqskkl] 78[c03ab2235b] yo[stqsxwqrlt] 401[119280761] vr[uxwmqvtpmx] bc9[e8942b459] yq[osqzytrlsw] 28[edbc9658ef] ro[yxmykxtrkr] af[3e6a27a1d0] mz[vwutvlkqwt] 04[6c6a1df762] qpv[untsmwlqt] 82[16f646c36d] zzz[zzzzzzzzz] 00[0000000000] [EOF] "); // The shortest prefix "zzz" is shadowed by bookmark work_dir .run_jj(["bookmark", "set", "-r@", "z", "zz", "zzz"]) .success(); insta::assert_snapshot!( render("root()", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" zzzz[zzzzzzzz] 00[0000000000] [EOF] ");} #[test]fn test_log_bad_short_prefixes() {Lines 1–500 of 1685. Load more
// Copyright 2022 The Jujutsu Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use crate::common::TestEnvironment; use crate::common::to_toml_value; #[test] fn test_log_with_empty_revision() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-r="]); insta::assert_snapshot!(output, @r" ------- stderr ------- error: a value is required for '--revisions <REVSETS>' but none was supplied For more information, try '--help'. [EOF] [exit status: 2] "); } #[test] fn test_log_with_no_template() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-T"]); insta::assert_snapshot!(output, @r" ------- stderr ------- error: a value is required for '--template <TEMPLATE>' but none was supplied For more information, try '--help'. Hint: The following template aliases are defined: - builtin_config_list - builtin_config_list_detailed - builtin_draft_commit_description - builtin_log_comfortable - builtin_log_compact - builtin_log_compact_full_description - builtin_log_detailed - builtin_log_node - builtin_log_node_ascii - builtin_log_oneline - builtin_op_log_comfortable - builtin_op_log_compact - builtin_op_log_node - builtin_op_log_node_ascii - builtin_op_log_oneline - commit_summary_separator - default_commit_description - description_placeholder - email_placeholder - git_format_patch_email_headers - name_placeholder [EOF] [exit status: 2] "); } #[test] fn test_log_with_or_without_diff() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.write_file("file1", "foo\n"); work_dir.run_jj(["describe", "-m", "add a file"]).success(); work_dir.run_jj(["new", "-m", "a new commit"]).success(); work_dir.write_file("file1", "foo\nbar\n"); let output = work_dir.run_jj(["log", "-T", "description"]); insta::assert_snapshot!(output, @r" @ a new commit ○ add a file ◆ [EOF] "); let output = work_dir.run_jj(["log", "-T", "description", "-p"]); insta::assert_snapshot!(output, @r" @ a new commit │ Modified regular file file1: │ 1 1: foo │ 2: bar ○ add a file │ Added regular file file1: │ 1: foo ◆ [EOF] "); let output = work_dir.run_jj(["log", "-T", "description", "--no-graph"]); insta::assert_snapshot!(output, @r" a new commit add a file [EOF] "); // `-p` for default diff output, `-s` for summary let output = work_dir.run_jj(["log", "-T", "description", "-p", "-s"]); insta::assert_snapshot!(output, @r" @ a new commit │ M file1 │ Modified regular file file1: │ 1 1: foo │ 2: bar ○ add a file │ A file1 │ Added regular file file1: │ 1: foo ◆ [EOF] "); // `-s` for summary, `--git` for git diff (which implies `-p`) let output = work_dir.run_jj(["log", "-T", "description", "-s", "--git"]); insta::assert_snapshot!(output, @r" @ a new commit │ M file1 │ diff --git a/file1 b/file1 │ index 257cc5642c..3bd1f0e297 100644 │ --- a/file1 │ +++ b/file1 │ @@ -1,1 +1,2 @@ │ foo │ +bar ○ add a file │ A file1 │ diff --git a/file1 b/file1 │ new file mode 100644 │ index 0000000000..257cc5642c │ --- /dev/null │ +++ b/file1 │ @@ -0,0 +1,1 @@ │ +foo ◆ [EOF] "); // `-p` for default diff output, `--stat` for diff-stat let output = work_dir.run_jj(["log", "-T", "description", "-p", "--stat"]); insta::assert_snapshot!(output, @r" @ a new commit │ file1 | 1 + │ 1 file changed, 1 insertion(+), 0 deletions(-) │ Modified regular file file1: │ 1 1: foo │ 2: bar ○ add a file │ file1 | 1 + │ 1 file changed, 1 insertion(+), 0 deletions(-) │ Added regular file file1: │ 1: foo ◆ 0 files changed, 0 insertions(+), 0 deletions(-) [EOF] "); // `--stat` is short format, which should be printed first let output = work_dir.run_jj(["log", "-T", "description", "--git", "--stat"]); insta::assert_snapshot!(output, @r" @ a new commit │ file1 | 1 + │ 1 file changed, 1 insertion(+), 0 deletions(-) │ diff --git a/file1 b/file1 │ index 257cc5642c..3bd1f0e297 100644 │ --- a/file1 │ +++ b/file1 │ @@ -1,1 +1,2 @@ │ foo │ +bar ○ add a file │ file1 | 1 + │ 1 file changed, 1 insertion(+), 0 deletions(-) │ diff --git a/file1 b/file1 │ new file mode 100644 │ index 0000000000..257cc5642c │ --- /dev/null │ +++ b/file1 │ @@ -0,0 +1,1 @@ │ +foo ◆ 0 files changed, 0 insertions(+), 0 deletions(-) [EOF] "); // `-p` enables default "summary" output, so `-s` is noop let output = work_dir.run_jj([ "log", "-T", "description", "-p", "-s", "--config=ui.diff-formatter=:summary", ]); insta::assert_snapshot!(output, @r" @ a new commit │ M file1 ○ add a file │ A file1 ◆ [EOF] "); // `-p` enables default "color-words" diff output, so `--color-words` is noop let output = work_dir.run_jj(["log", "-T", "description", "-p", "--color-words"]); insta::assert_snapshot!(output, @r" @ a new commit │ Modified regular file file1: │ 1 1: foo │ 2: bar ○ add a file │ Added regular file file1: │ 1: foo ◆ [EOF] "); // `--git` enables git diff, so `-p` is noop let output = work_dir.run_jj(["log", "-T", "description", "--no-graph", "-p", "--git"]); insta::assert_snapshot!(output, @r" a new commit diff --git a/file1 b/file1 index 257cc5642c..3bd1f0e297 100644 --- a/file1 +++ b/file1 @@ -1,1 +1,2 @@ foo +bar add a file diff --git a/file1 b/file1 new file mode 100644 index 0000000000..257cc5642c --- /dev/null +++ b/file1 @@ -0,0 +1,1 @@ +foo [EOF] "); // Cannot use both `--git` and `--color-words` let output = work_dir.run_jj([ "log", "-T", "description", "--no-graph", "-p", "--git", "--color-words", ]); insta::assert_snapshot!(output, @r" ------- stderr ------- error: the argument '--git' cannot be used with '--color-words' Usage: jj log --template <TEMPLATE> --no-graph --patch --git [FILESETS]... For more information, try '--help'. [EOF] [exit status: 2] "); // `-s` with or without graph let output = work_dir.run_jj(["log", "-T", "description", "-s"]); insta::assert_snapshot!(output, @r" @ a new commit │ M file1 ○ add a file │ A file1 ◆ [EOF] "); let output = work_dir.run_jj(["log", "-T", "description", "--no-graph", "-s"]); insta::assert_snapshot!(output, @r" a new commit M file1 add a file A file1 [EOF] "); // `--git` implies `-p`, with or without graph let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--git"]); insta::assert_snapshot!(output, @r" @ a new commit │ diff --git a/file1 b/file1 ~ index 257cc5642c..3bd1f0e297 100644 --- a/file1 +++ b/file1 @@ -1,1 +1,2 @@ foo +bar [EOF] "); let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--no-graph", "--git"]); insta::assert_snapshot!(output, @r" a new commit diff --git a/file1 b/file1 index 257cc5642c..3bd1f0e297 100644 --- a/file1 +++ b/file1 @@ -1,1 +1,2 @@ foo +bar [EOF] "); // `--color-words` implies `-p`, with or without graph let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--color-words"]); insta::assert_snapshot!(output, @r" @ a new commit │ Modified regular file file1: ~ 1 1: foo 2: bar [EOF] "); let output = work_dir.run_jj([ "log", "-T", "description", "-r", "@", "--no-graph", "--color-words", ]); insta::assert_snapshot!(output, @r" a new commit Modified regular file file1: 1 1: foo 2: bar [EOF] "); } #[test] fn test_log_null_terminate_multiline_descriptions() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir .run_jj(["commit", "-m", "commit 1 line 1", "-m", "commit 1 line 2"]) .success(); work_dir .run_jj(["commit", "-m", "commit 2 line 1", "-m", "commit 2 line 2"]) .success(); work_dir .run_jj(["describe", "-m", "commit 3 line 1", "-m", "commit 3 line 2"]) .success(); let output = work_dir .run_jj([ "log", "-r", "~root()", "-T", r#"description ++ "\0""#, "--no-graph", ]) .success(); insta::assert_debug_snapshot!( output.stdout.normalized(), @r#""commit 3 line 1\n\ncommit 3 line 2\n\0commit 2 line 1\n\ncommit 2 line 2\n\0commit 1 line 1\n\ncommit 1 line 2\n\0""# ); } #[test] fn test_log_shortest_accessors() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let render = |rev, template| work_dir.run_jj(["log", "--no-graph", "-r", rev, "-T", template]); test_env.add_config( r#" [template-aliases] 'format_id(id)' = 'id.shortest(12).prefix() ++ "[" ++ id.shortest(12).rest() ++ "]"' "#, ); work_dir.write_file("file", "original file\n"); work_dir.run_jj(["describe", "-m", "initial"]).success(); work_dir .run_jj(["bookmark", "c", "-r@", "original"]) .success(); insta::assert_snapshot!( render("original", r#"format_id(change_id) ++ " " ++ format_id(commit_id)"#), @"q[pvuntsmwlqt] 8[216f646c36d][EOF]"); // Create a chain of 10 commits for i in 1..10 { work_dir .run_jj(["new", "-m", &format!("commit{i}")]) .success(); work_dir.write_file("file", format!("file {i}\n")); } // Create 2^3 duplicates of the chain for _ in 0..3 { work_dir .run_jj(["duplicate", "description(commit)"]) .success(); } insta::assert_snapshot!( render("original", r#"format_id(change_id) ++ " " ++ format_id(commit_id)"#), @"qpv[untsmwlqt] 82[16f646c36d][EOF]"); insta::assert_snapshot!( render("::@", r#"change_id.shortest() ++ " " ++ commit_id.shortest() ++ "\n""#), @r" wq c2 km 74 kp 97 zn 78 yo 40 vr bc9 yq 28 ro af mz 04 qpv 82 zzz 00 [EOF] "); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" wq[nwkozpkust] c2[b4c0bb3362] km[kuslswpqwq] 74[fcd50c0643] kp[qxywonksrl] 97[dcaada9b8d] zn[kkpsqqskkl] 78[c03ab2235b] yo[stqsxwqrlt] 40[1119280761] vr[uxwmqvtpmx] bc9[e8942b459] yq[osqzytrlsw] 28[edbc9658ef] ro[yxmykxtrkr] af[3e6a27a1d0] mz[vwutvlkqwt] 04[6c6a1df762] qpv[untsmwlqt] 82[16f646c36d] zzz[zzzzzzzzz] 00[0000000000] [EOF] "); // Can get shorter prefixes in configured revset test_env.add_config(r#"revsets.short-prefixes = "(@----)::""#); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" w[qnwkozpkust] c[2b4c0bb3362] km[kuslswpqwq] 74[fcd50c0643] kp[qxywonksrl] 9[7dcaada9b8d] z[nkkpsqqskkl] 78[c03ab2235b] y[ostqsxwqrlt] 4[01119280761] vr[uxwmqvtpmx] bc9[e8942b459] yq[osqzytrlsw] 28[edbc9658ef] ro[yxmykxtrkr] af[3e6a27a1d0] mz[vwutvlkqwt] 04[6c6a1df762] qpv[untsmwlqt] 82[16f646c36d] zzz[zzzzzzzzz] 00[0000000000] [EOF] "); // Can disable short prefixes by setting to empty string test_env.add_config(r#"revsets.short-prefixes = """#); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" wq[nwkozpkust] c2[b4c0bb3362] km[kuslswpqwq] 74[fcd50c0643] kp[qxywonksrl] 97[dcaada9b8d] zn[kkpsqqskkl] 78[c03ab2235b] yo[stqsxwqrlt] 401[119280761] vr[uxwmqvtpmx] bc9[e8942b459] yq[osqzytrlsw] 28[edbc9658ef] ro[yxmykxtrkr] af[3e6a27a1d0] mz[vwutvlkqwt] 04[6c6a1df762] qpv[untsmwlqt] 82[16f646c36d] zzz[zzzzzzzzz] 00[0000000000] [EOF] "); // The shortest prefix "zzz" is shadowed by bookmark work_dir .run_jj(["bookmark", "set", "-r@", "z", "zz", "zzz"]) .success(); insta::assert_snapshot!( render("root()", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" zzzz[zzzzzzzz] 00[0000000000] [EOF] "); } #[test] fn test_log_bad_short_prefixes() {