mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 08:53:16 +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;
|
use crate::formatter::Formatter;
|
||||||
|
|
||||||
#[derive(clap::Args, Clone, Debug)]
|
#[derive(clap::Args, Clone, Debug)]
|
||||||
|
#[command(group(clap::ArgGroup::new("diff-format").args(&["git", "color_words"])))]
|
||||||
pub struct DiffFormatArgs {
|
pub struct DiffFormatArgs {
|
||||||
/// For each path, show only whether it was modified, added, or removed
|
/// For each path, show only whether it was modified, added, or removed
|
||||||
#[arg(long, short)]
|
#[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]
|
#[test]
|
||||||
fn test_diff_relative_paths() {
|
fn test_diff_relative_paths() {
|
||||||
let test_env = TestEnvironment::default();
|
let test_env = TestEnvironment::default();
|
||||||
|
|
|
@ -165,8 +165,8 @@ fn test_log_with_or_without_diff() {
|
||||||
+foo
|
+foo
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
// Both formats enabled if `--git` and `--color-words` are explicitly specified
|
// Cannot use both `--git` and `--color-words`
|
||||||
let stdout = test_env.jj_cmd_success(
|
let stderr = test_env.jj_cmd_cli_error(
|
||||||
&repo_path,
|
&repo_path,
|
||||||
&[
|
&[
|
||||||
"log",
|
"log",
|
||||||
|
@ -178,28 +178,12 @@ fn test_log_with_or_without_diff() {
|
||||||
"--color-words",
|
"--color-words",
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
insta::assert_snapshot!(stdout, @r###"
|
insta::assert_snapshot!(stderr, @r###"
|
||||||
a new commit
|
error: The argument '--git' cannot be used with '--color-words'
|
||||||
diff --git a/file1 b/file1
|
|
||||||
index 257cc5642c...3bd1f0e297 100644
|
Usage: jj log --template <TEMPLATE> --no-graph --patch --git [PATHS]...
|
||||||
--- a/file1
|
|
||||||
+++ b/file1
|
For more information try '--help'
|
||||||
@@ -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
|
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
// `-s` with or without graph
|
// `-s` with or without graph
|
||||||
|
|
Loading…
Reference in a new issue