ok/jj
1
0
Fork 0
forked from mirrors/jj

diff: omit rename source entries from color-words diffs

Rename source entries will be handled by CopiesTreeDiffStream.
This commit is contained in:
Yuya Nishihara 2024-08-20 23:14:27 +09:00
parent 2cffcc9323
commit 7684ab5994
4 changed files with 13 additions and 13 deletions

View file

@ -1355,6 +1355,7 @@ fn builtin_tree_diff_methods<'repo>() -> CommitTemplateBuildMethodFnMap<'repo, T
formatter,
store,
tree_diff,
&Default::default(), // TODO: real copy tracking
path_converter,
&options,
)

View file

@ -328,7 +328,14 @@ impl<'a> DiffRenderer<'a> {
DiffFormat::ColorWords(options) => {
let tree_diff =
from_tree.diff_stream_with_copies(to_tree, matcher, copy_records);
show_color_words_diff(formatter, store, tree_diff, path_converter, options)?;
show_color_words_diff(
formatter,
store,
tree_diff,
copy_records,
path_converter,
options,
)?;
}
DiffFormat::Tool(tool) => {
match tool.diff_invocation_mode {
@ -752,6 +759,7 @@ pub fn show_color_words_diff(
formatter: &mut dyn Formatter,
store: &Store,
tree_diff: BoxStream<CopiesTreeDiffEntry>,
copy_records: &CopyRecords,
path_converter: &RepoPathUiConverter,
options: &ColorWordsOptions,
) -> Result<(), DiffRenderError> {
@ -766,6 +774,9 @@ pub fn show_color_words_diff(
let left_ui_path = path_converter.format_file_path(&left_path);
let right_ui_path = path_converter.format_file_path(&right_path);
let (left_value, right_value) = diff?;
if right_value.is_absent() && copy_records.has_source(&left_path) {
continue;
}
match (&left_value, &right_value) {
(MaterializedTreeValue::AccessDenied(source), _) => {

View file

@ -33,8 +33,6 @@ fn test_diff_basic() {
let stdout = test_env.jj_cmd_success(&repo_path, &["diff"]);
insta::assert_snapshot!(stdout, @r###"
Removed regular file file1:
1 : foo
Modified regular file file2:
1 1: 1
2 2: 25
@ -46,8 +44,6 @@ fn test_diff_basic() {
let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "--context=0"]);
insta::assert_snapshot!(stdout, @r###"
Removed regular file file1:
1 : foo
Modified regular file file2:
1 1: 1
2 2: 25
@ -59,8 +55,6 @@ fn test_diff_basic() {
let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "--color=debug"]);
insta::assert_snapshot!(stdout, @r###"
<<diff header::Removed regular file file1:>>
<<diff removed line_number:: 1>><<diff:: : >><<diff removed token::foo>>
<<diff header::Modified regular file file2:>>
<<diff removed line_number:: 1>><<diff:: >><<diff added line_number:: 1>><<diff::: 1>>
<<diff removed line_number:: 2>><<diff:: >><<diff added line_number:: 2>><<diff::: >><<diff removed token::2>><<diff added token::5>><<diff::>>

View file

@ -56,8 +56,6 @@ fn test_show_basic() {
(no description set)
Removed regular file file1:
1 : foo
Modified regular file file2:
1 1: foo
2: bar
@ -74,8 +72,6 @@ fn test_show_basic() {
(no description set)
Removed regular file file1:
1 : foo
Modified regular file file2:
1 1: foo
2: bar
@ -92,8 +88,6 @@ fn test_show_basic() {
<<description placeholder:: (no description set)>>
<<diff header::Removed regular file file1:>>
<<diff removed line_number:: 1>><<diff:: : >><<diff removed token::foo>>
<<diff header::Modified regular file file2:>>
<<diff removed line_number:: 1>><<diff:: >><<diff added line_number:: 1>><<diff::: foo>>
<<diff:: >><<diff added line_number:: 2>><<diff::: >><<diff added token::bar>>