diff --git a/src/diff_util.rs b/src/diff_util.rs index de507ac07..8c8d7c0d4 100644 --- a/src/diff_util.rs +++ b/src/diff_util.rs @@ -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 { - (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 { diff --git a/tests/test_log_command.rs b/tests/test_log_command.rs index 737980039..c99386ce1 100644 --- a/tests/test_log_command.rs +++ b/tests/test_log_command.rs @@ -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]