diff options
author | Dan Davison <dandavison7@gmail.com> | 2022-03-16 09:47:33 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2022-03-16 09:47:33 -0400 |
commit | 29710e1f9551876dfd10fe0119ddea8a17e8830b (patch) | |
tree | ed6548cfd3aa527b5bdd3b55e39dd7adce3ba587 | |
parent | dd19c974baadae1a1565067130b3eb81770123b1 (diff) |
Use file paths from arguments in preference to those in diff input1014-diff-mode-absolute-paths
Fixes #1014
-rw-r--r-- | src/handlers/diff_header.rs | 12 | ||||
-rw-r--r-- | src/handlers/hunk_header.rs | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/handlers/diff_header.rs b/src/handlers/diff_header.rs index 3e317bee..50e1f7aa 100644 --- a/src/handlers/diff_header.rs +++ b/src/handlers/diff_header.rs @@ -155,8 +155,16 @@ impl<'a> StateMachine<'a> { /// Construct file change line from minus and plus file and write with DiffHeader styling. fn _handle_diff_header_header_line(&mut self, comparing: bool) -> std::io::Result<()> { let line = get_file_change_description_from_file_paths( - &self.minus_file, - &self.plus_file, + self.config + .minus_file + .as_ref() + .and_then(|p| p.to_str()) + .unwrap_or(&self.minus_file), + self.config + .plus_file + .as_ref() + .and_then(|p| p.to_str()) + .unwrap_or(&self.plus_file), comparing, &self.minus_file_event, &self.plus_file_event, diff --git a/src/handlers/hunk_header.rs b/src/handlers/hunk_header.rs index 7a9e2a1c..516394d8 100644 --- a/src/handlers/hunk_header.rs +++ b/src/handlers/hunk_header.rs @@ -263,7 +263,11 @@ fn paint_file_path_with_line_number( paint::paint_file_path_with_line_number( line_number, - plus_file, + config + .plus_file + .as_ref() + .and_then(|p| p.to_str()) + .unwrap_or(plus_file), false, ":", false, |