cli: enable diff output by 'log --color-words'

It doesn't make sense that --git implies -p, but --color-words doesn't.
This commit is contained in:
Yuya Nishihara 2022-12-14 19:48:53 +09:00
parent b4d6c9e8da
commit 69e57daa64
2 changed files with 31 additions and 1 deletions

View file

@ -67,7 +67,7 @@ pub fn diff_format_for(ui: &Ui, args: &DiffFormatArgs) -> DiffFormat {
}
pub fn diff_format_for_log(ui: &Ui, args: &DiffFormatArgs, patch: bool) -> Option<DiffFormat> {
(patch || args.git || args.summary).then(|| diff_format_for(ui, args))
(patch || args.git || args.color_words || args.summary).then(|| diff_format_for(ui, args))
}
fn default_diff_format(ui: &Ui) -> DiffFormat {

View file

@ -142,6 +142,36 @@ fn test_log_with_or_without_diff() {
foo
+bar
"###);
// `--color-words` implies `-p`, with or without graph
let stdout = test_env.jj_cmd_success(
&repo_path,
&["log", "-T", "description", "-r", "@", "--color-words"],
);
insta::assert_snapshot!(stdout, @r###"
@ a new commit
~ Modified regular file file1:
1 1: foo
2: bar
"###);
let stdout = test_env.jj_cmd_success(
&repo_path,
&[
"log",
"-T",
"description",
"-r",
"@",
"--no-graph",
"--color-words",
],
);
insta::assert_snapshot!(stdout, @r###"
a new commit
Modified regular file file1:
1 1: foo
2: bar
"###);
}
#[test]