mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 00:44:33 +00:00
cli: disallow jj diff --color-words --git
This commit is contained in:
parent
0899260f0c
commit
ed1c2ea1aa
3 changed files with 25 additions and 24 deletions
|
@ -33,6 +33,7 @@ use crate::cli_util::{CommandError, WorkspaceCommandHelper};
|
|||
use crate::formatter::Formatter;
|
||||
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
#[command(group(clap::ArgGroup::new("diff-format").args(&["git", "color_words"])))]
|
||||
pub struct DiffFormatArgs {
|
||||
/// For each path, show only whether it was modified, added, or removed
|
||||
#[arg(long, short)]
|
||||
|
|
|
@ -101,6 +101,22 @@ fn test_diff_basic() {
|
|||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_diff_bad_args() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["diff", "--color-words", "--git"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
error: The argument '--color-words' cannot be used with '--git'
|
||||
|
||||
Usage: jj diff --color-words [PATHS]...
|
||||
|
||||
For more information try '--help'
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_diff_relative_paths() {
|
||||
let test_env = TestEnvironment::default();
|
||||
|
|
|
@ -165,8 +165,8 @@ fn test_log_with_or_without_diff() {
|
|||
+foo
|
||||
"###);
|
||||
|
||||
// Both formats enabled if `--git` and `--color-words` are explicitly specified
|
||||
let stdout = test_env.jj_cmd_success(
|
||||
// Cannot use both `--git` and `--color-words`
|
||||
let stderr = test_env.jj_cmd_cli_error(
|
||||
&repo_path,
|
||||
&[
|
||||
"log",
|
||||
|
@ -178,28 +178,12 @@ fn test_log_with_or_without_diff() {
|
|||
"--color-words",
|
||||
],
|
||||
);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
a new commit
|
||||
diff --git a/file1 b/file1
|
||||
index 257cc5642c...3bd1f0e297 100644
|
||||
--- a/file1
|
||||
+++ b/file1
|
||||
@@ -1,1 +1,2 @@
|
||||
foo
|
||||
+bar
|
||||
Modified regular file file1:
|
||||
1 1: foo
|
||||
2: bar
|
||||
add a file
|
||||
diff --git a/file1 b/file1
|
||||
new file mode 100644
|
||||
index 0000000000..257cc5642c
|
||||
--- /dev/null
|
||||
+++ b/file1
|
||||
@@ -1,0 +1,1 @@
|
||||
+foo
|
||||
Added regular file file1:
|
||||
1: foo
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
error: The argument '--git' cannot be used with '--color-words'
|
||||
|
||||
Usage: jj log --template <TEMPLATE> --no-graph --patch --git [PATHS]...
|
||||
|
||||
For more information try '--help'
|
||||
"###);
|
||||
|
||||
// `-s` with or without graph
|
||||
|
|
Loading…
Reference in a new issue