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:
parent
2cffcc9323
commit
7684ab5994
4 changed files with 13 additions and 13 deletions
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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), _) => {
|
||||
|
|
|
@ -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###"
|
||||
[38;5;3m<<diff header::Removed regular file file1:>>[39m
|
||||
[38;5;1m<<diff removed line_number:: 1>>[39m<<diff:: : >>[4m[38;5;1m<<diff removed token::foo>>[24m[39m
|
||||
[38;5;3m<<diff header::Modified regular file file2:>>[39m
|
||||
[38;5;1m<<diff removed line_number:: 1>>[39m<<diff:: >>[38;5;2m<<diff added line_number:: 1>>[39m<<diff::: 1>>
|
||||
[38;5;1m<<diff removed line_number:: 2>>[39m<<diff:: >>[38;5;2m<<diff added line_number:: 2>>[39m<<diff::: >>[4m[38;5;1m<<diff removed token::2>>[38;5;2m<<diff added token::5>>[24m[39m<<diff::>>
|
||||
|
|
|
@ -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() {
|
|||
|
||||
[38;5;3m<<description placeholder:: (no description set)>>[39m
|
||||
|
||||
[38;5;3m<<diff header::Removed regular file file1:>>[39m
|
||||
[38;5;1m<<diff removed line_number:: 1>>[39m<<diff:: : >>[4m[38;5;1m<<diff removed token::foo>>[24m[39m
|
||||
[38;5;3m<<diff header::Modified regular file file2:>>[39m
|
||||
[38;5;1m<<diff removed line_number:: 1>>[39m<<diff:: >>[38;5;2m<<diff added line_number:: 1>>[39m<<diff::: foo>>
|
||||
<<diff:: >>[38;5;2m<<diff added line_number:: 2>>[39m<<diff::: >>[4m[38;5;2m<<diff added token::bar>>[24m[39m
|
||||
|
|
Loading…
Reference in a new issue