// 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::to_toml_value;use crate::common::TestEnvironment; #[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 - description_placeholder - email_placeholder - 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.format=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] e[0e22b9fae75][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] e0[e22b9fae75][EOF]"); insta::assert_snapshot!( render("::@", r#"change_id.shortest() ++ " " ++ commit_id.shortest() ++ "\n""#), @r" wq ed km ef3 kp af zn 23 yo b87 vr 1e yq 34 ro cc mz 1b qpv e0 zzz 00 [EOF] "); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" wq[nwkozpkust] ed[e204633421] km[kuslswpqwq] ef3[d013266cd] kp[qxywonksrl] af[95b841712d] zn[kkpsqqskkl] 23[c1103d3427] yo[stqsxwqrlt] b87[aa9b24921] vr[uxwmqvtpmx] 1e[a31a205ce9] yq[osqzytrlsw] 34[befb94f4eb] ro[yxmykxtrkr] cc[0c127948ef] mz[vwutvlkqwt] 1b[7b715afc3f] qpv[untsmwlqt] e0[e22b9fae75] 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] ed[e204633421] km[kuslswpqwq] ef[3d013266cd] kp[qxywonksrl] a[f95b841712d] z[nkkpsqqskkl] 2[3c1103d3427] y[ostqsxwqrlt] b[87aa9b24921] vr[uxwmqvtpmx] 1e[a31a205ce9] yq[osqzytrlsw] 34[befb94f4eb] ro[yxmykxtrkr] cc[0c127948ef] mz[vwutvlkqwt] 1b[7b715afc3f] qpv[untsmwlqt] e0[e22b9fae75] 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] ed[e204633421] km[kuslswpqwq] ef3[d013266cd] kp[qxywonksrl] af[95b841712d] zn[kkpsqqskkl] 23c[1103d3427] yo[stqsxwqrlt] b87[aa9b24921] vr[uxwmqvtpmx] 1e[a31a205ce9] yq[osqzytrlsw] 34[befb94f4eb] ro[yxmykxtrkr] cc[0c127948ef] mz[vwutvlkqwt] 1b[7b715afc3f] qpv[untsmwlqt] e0[e22b9fae75] zzz[zzzzzzzzz] 00[0000000000] [EOF] ");} #[test]fn test_log_bad_short_prefixes() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); // Suppress warning in the commit summary template test_env.add_config("template-aliases.'format_short_id(id)' = 'id.short(8)'"); // Error on bad config of short prefixes test_env.add_config(r#"revsets.short-prefixes = "!nval!d""#); let output = work_dir.run_jj(["status"]); insta::assert_snapshot!(output, @r" ------- stderr -------Lines 1–500 of 1706. 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::to_toml_value; use crate::common::TestEnvironment; #[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 - description_placeholder - email_placeholder - 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.format=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] e[0e22b9fae75][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] e0[e22b9fae75][EOF]"); insta::assert_snapshot!( render("::@", r#"change_id.shortest() ++ " " ++ commit_id.shortest() ++ "\n""#), @r" wq ed km ef3 kp af zn 23 yo b87 vr 1e yq 34 ro cc mz 1b qpv e0 zzz 00 [EOF] "); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r" wq[nwkozpkust] ed[e204633421] km[kuslswpqwq] ef3[d013266cd] kp[qxywonksrl] af[95b841712d] zn[kkpsqqskkl] 23[c1103d3427] yo[stqsxwqrlt] b87[aa9b24921] vr[uxwmqvtpmx] 1e[a31a205ce9] yq[osqzytrlsw] 34[befb94f4eb] ro[yxmykxtrkr] cc[0c127948ef] mz[vwutvlkqwt] 1b[7b715afc3f] qpv[untsmwlqt] e0[e22b9fae75] 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] ed[e204633421] km[kuslswpqwq] ef[3d013266cd] kp[qxywonksrl] a[f95b841712d] z[nkkpsqqskkl] 2[3c1103d3427] y[ostqsxwqrlt] b[87aa9b24921] vr[uxwmqvtpmx] 1e[a31a205ce9] yq[osqzytrlsw] 34[befb94f4eb] ro[yxmykxtrkr] cc[0c127948ef] mz[vwutvlkqwt] 1b[7b715afc3f] qpv[untsmwlqt] e0[e22b9fae75] 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] ed[e204633421] km[kuslswpqwq] ef3[d013266cd] kp[qxywonksrl] af[95b841712d] zn[kkpsqqskkl] 23c[1103d3427] yo[stqsxwqrlt] b87[aa9b24921] vr[uxwmqvtpmx] 1e[a31a205ce9] yq[osqzytrlsw] 34[befb94f4eb] ro[yxmykxtrkr] cc[0c127948ef] mz[vwutvlkqwt] 1b[7b715afc3f] qpv[untsmwlqt] e0[e22b9fae75] zzz[zzzzzzzzz] 00[0000000000] [EOF] "); } #[test] fn test_log_bad_short_prefixes() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); // Suppress warning in the commit summary template test_env.add_config("template-aliases.'format_short_id(id)' = 'id.short(8)'"); // Error on bad config of short prefixes test_env.add_config(r#"revsets.short-prefixes = "!nval!d""#); let output = work_dir.run_jj(["status"]); insta::assert_snapshot!(output, @r" ------- stderr -------