summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/main.rs6
-rw-r--r--src/paint.rs3
-rw-r--r--src/parse.rs32
4 files changed, 27 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index c4204dd6..71b4c521 100644
--- a/Makefile
+++ b/Makefile
@@ -4,4 +4,4 @@ build:
test:
cargo test
- bash -c "diff -u <(git log -p | cut -c 2-) <(git log -p | delta --width variable | ansifilter | cut -c 2-)"
+ bash -c "diff -u <(git log -p | cut -c 2-) <(git log -p | delta --width variable --no-structural-changes | ansifilter | cut -c 2-)"
diff --git a/src/main.rs b/src/main.rs
index 196169fa..d3472aaa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -62,6 +62,11 @@ struct Opt {
/// apply syntax highlighting to unchanged and new lines only.
highlight_removed: bool,
+ #[structopt(long = "no-structural-changes")]
+ /// Do not modify input text; only add colors. This disables
+ /// prettification of metadata sections in the git diff output.
+ no_structural_changes: bool,
+
/// The width (in characters) of the background color
/// highlighting. By default, the width is the current terminal
/// width. Use --width=variable to apply background colors to the
@@ -171,6 +176,7 @@ fn process_command_line_arguments<'a>(
&opt.plus_color,
&opt.plus_emph_color,
opt.highlight_removed,
+ opt.no_structural_changes,
terminal_width,
width,
)
diff --git a/src/paint.rs b/src/paint.rs
index c861c099..71882f22 100644
--- a/src/paint.rs
+++ b/src/paint.rs
@@ -96,6 +96,7 @@ pub struct Config<'a> {
pub terminal_width: usize,
pub width: Option<usize>,
pub highlight_removed: bool,
+ pub no_structural_changes: bool,
pub pager: &'a str,
}
@@ -109,6 +110,7 @@ pub fn get_config<'a>(
plus_color: &Option<String>,
plus_emph_color: &Option<String>,
highlight_removed: bool,
+ no_structural_changes: bool,
terminal_width: usize,
width: Option<usize>,
) -> Config<'a> {
@@ -182,6 +184,7 @@ pub fn get_config<'a>(
terminal_width: terminal_width,
width: width,
highlight_removed: highlight_removed,
+ no_structural_changes: no_structural_changes,
syntax_set: &syntax_set,
pager: "less",
}
diff --git a/src/parse.rs b/src/parse.rs
index 3261aa38..f1583cc7 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -71,20 +71,22 @@ pub fn delta(
Some(extension) => assets.syntax_set.find_syntax_by_extension(extension),
None => None,
};
- painter.emit()?;
- let hline = "─".repeat(config.terminal_width);
- let file_paths = get_file_paths_from_diff_line(&line);
-
- let ansi_style = Blue.bold();
- writeln!(
- painter.writer,
- "{}\n{}{}\n{}",
- ansi_style.paint(&hline),
- ansi_style.paint("modified: "),
- ansi_style.paint(file_paths.0.unwrap_or("?")),
- ansi_style.paint(&hline)
- )?;
- continue;
+ if !config.no_structural_changes {
+ painter.emit()?;
+ let hline = "─".repeat(config.terminal_width);
+ let file_paths = get_file_paths_from_diff_line(&line);
+
+ let ansi_style = Blue.bold();
+ writeln!(
+ painter.writer,
+ "{}\n{}{}\n{}",
+ ansi_style.paint(&hline),
+ ansi_style.paint("modified: "),
+ ansi_style.paint(file_paths.0.unwrap_or("?")),
+ ansi_style.paint(&hline)
+ )?;
+ continue;
+ }
} else if line.starts_with("commit") {
painter.paint_buffered_lines();
state = State::Commit;
@@ -116,7 +118,7 @@ pub fn delta(
painter.emit()?;
continue;
}
- if state == State::DiffMeta {
+ if state == State::DiffMeta && !config.no_structural_changes {
continue;
} else {
painter.emit()?;