diff --git a/Cargo.lock b/Cargo.lock index 93d21a4c2..beb6e4d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -354,7 +354,7 @@ dependencies = [ [[package]] name = "git-delta" -version = "0.10.1" +version = "0.10.2" dependencies = [ "ansi_colours", "ansi_term 0.12.1", diff --git a/Cargo.toml b/Cargo.toml index 5080d1c78..c699db2c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" homepage = "https://github.com/dandavison/delta" license = "MIT" repository = "https://github.com/dandavison/delta" -version = "0.10.1" +version = "0.10.2" [[bin]] name = "delta" diff --git a/HomeBrewFormula/git-delta.rb b/HomeBrewFormula/git-delta.rb index 8477e95d4..95f10bbf4 100644 --- a/HomeBrewFormula/git-delta.rb +++ b/HomeBrewFormula/git-delta.rb @@ -1,5 +1,5 @@ class GitDelta < Formula - version "0.9.2" + version "0.10.1" desc "A viewer for git and diff output" homepage "https://github.com/dandavison/delta" @@ -7,10 +7,10 @@ class GitDelta < Formula if OS.mac? url "https://github.com/dandavison/delta/releases/download/#{version}/delta-#{version}-x86_64-apple-darwin.tar.gz" - sha256 "c35e750dd45f3991c1fab09d75e585d636002c5824a531200a29ca5db4cd18eb" + sha256 "a079a6d807d104ff084c783f5731eeee0ba59b684e0562dee12d2cb4a33ca48c" elsif OS.linux? url "https://github.com/dandavison/delta/releases/download/#{version}/delta-#{version}-x86_64-unknown-linux-musl.tar.gz" - sha256 "4d0e55785fb97f7c304eb1bda24a5ed8894ddef50f74573b6528b47ae67e9996" + sha256 "049db453e2299c964a7d4ceb274f0af6450147196a31db8b3df8f37666270a16" end conflicts_with "delta" diff --git a/README.md b/README.md index 3c408fff2..79f7eb72d 100644 --- a/README.md +++ b/README.md @@ -176,13 +176,13 @@ In addition, delta handles traditional unified diff output. ## Installation You can download an executable for your system: -[Linux (glibc)](https://github.com/dandavison/delta/releases/download/0.9.1/delta-0.9.1-x86_64-unknown-linux-gnu.tar.gz) +[Linux (glibc)](https://github.com/dandavison/delta/releases/download/0.10.1/delta-0.10.1-x86_64-unknown-linux-gnu.tar.gz) | -[Linux (musl)](https://github.com/dandavison/delta/releases/download/0.9.1/delta-0.9.1-x86_64-unknown-linux-musl.tar.gz) +[Linux (musl)](https://github.com/dandavison/delta/releases/download/0.10.1/delta-0.10.1-x86_64-unknown-linux-musl.tar.gz) | -[MacOS](https://github.com/dandavison/delta/releases/download/0.9.1/delta-0.9.1-x86_64-apple-darwin.tar.gz) +[MacOS](https://github.com/dandavison/delta/releases/download/0.10.1/delta-0.10.1-x86_64-apple-darwin.tar.gz) | -[Windows](https://github.com/dandavison/delta/releases/download/0.9.1/delta-0.9.1-x86_64-pc-windows-msvc.zip) +[Windows](https://github.com/dandavison/delta/releases/download/0.10.1/delta-0.10.1-x86_64-pc-windows-msvc.zip) | [All](https://github.com/dandavison/delta/releases) @@ -266,11 +266,8 @@ The most convenient way to configure delta is with a `[delta]` section in `~/.gi ```gitconfig -[pager] - diff = delta - log = delta - reflog = delta - show = delta +[core] + pager = delta [interactive] diffFilter = delta --color-only --features=interactive @@ -707,7 +704,7 @@ and use the executable found at `./target/release/delta`. ## Full --help output ``` -delta 0.9.1 +delta 0.10.1 A viewer for git and diff output USAGE: @@ -756,6 +753,11 @@ FLAGS: according to whether delta is in dark or light mode (as set by the user or inferred from BAT_THEME). To control the themes shown, use --dark or --light, or both, on the command line together with this option + --show-colors Show available named colors. In addition to named colors, arbitrary colors can be + specified using RGB hex codes. See COLORS section + --parse-ansi Parse ANSI color escape sequences in input and display them as git style strings. + Example usage: git show --color=always | delta --parse-ansi This can be used to + help identify input style strings to use with map-styles --no-gitconfig Do not take any settings from git config. See GIT CONFIG section --raw Do not alter the input in any way. This is mainly intended for testing delta --color-only Do not alter the input structurally in any way, but color and highlight hunk lines @@ -838,6 +840,38 @@ OPTIONS: Style (foreground, background, attributes) for the hunk-header decoration. See STYLES section. The style string should contain one of the special attributes 'box', 'ul' (underline), 'ol' (overline), or the combination 'ul ol' [default: blue box] + --map-styles + A string specifying a mapping styles encountered in raw input to desired output styles. An example is --map- + styles='bold purple => red "#eeeeee", bold cyan => syntax "#eeeeee"' + --blame-format + Format string for git blame commit metadata. Available placeholders are "{timestamp}", "{author}", and + "{commit}" [default: {timestamp:<15} {author:<15.14} {commit:<8} │ ] + --blame-palette + Background colors used for git blame lines (space-separated string). Lines added by the same commit are + painted with the same color; colors are recycled as needed + --blame-timestamp-format + Format of `git blame` timestamp in raw git output received by delta [default: %Y-%m-%d %H:%M:%S %z] + + --grep-match-line-style + Style (foreground, background, attributes) for matching lines of code in grep output. See STYLES section. + Defaults to plus-style + --grep-match-word-style + Style (foreground, background, attributes) for the specific matching substrings within a matching line of + code in grep output. See STYLES section. Defaults to plus-style + --grep-context-line-style + Style (foreground, background, attributes) for non-matching lines of code in grep output. See STYLES + section. Defaults to zero-style + --grep-file-style + Style (foreground, background, attributes) for file paths in grep output. See STYLES section. Defaults to + hunk-header-file-path-style + --grep-line-number-style + Style (foreground, background, attributes) for line numbers in grep output. See STYLES section. Defaults to + hunk-header-line-number-style + --grep-separator-symbol + Symbol used in grep output to separate file path (and line number) from the line of file contents. Defaults + to ":" for both match and context lines, since many terminal emulators recognize constructs like + "/path/to/file:7:". However, standard grep output uses "-" for context lines: set this option to "keep" to + keep the original separator symbols [default: :] --default-language Default language used for syntax highlighting when this cannot be inferred from a filename. It will typically make sense to set this in per-repository git config (.git/config) @@ -1088,15 +1122,19 @@ A complete description of the style string syntax follows: COLORS ------ -There are three ways to specify a color (this section applies to foreground and background colors +There are four ways to specify a color (this section applies to foreground and background colors within a style string): -1. RGB hex code +1. CSS color name + + Any of the 140 color names used in CSS: https://www.w3schools.com/colors/colors_groups.asp + +2. RGB hex code An example of using an RGB hex code is: --file-style="#0e7c0e" -2. ANSI color name +3. ANSI color name There are 8 ANSI color names: black, red, green, yellow, blue, magenta, cyan, white. @@ -1115,7 +1153,7 @@ within a style string): "purple" is accepted as a synonym for "magenta". Color names and codes are case-insensitive. -3. ANSI color number +4. ANSI color number An example of using an ANSI color number is: --file-style=28 diff --git a/etc/examples/72-color-moved-4.diff b/etc/examples/72-color-moved-4.diff new file mode 100644 index 000000000..9aa6fc6e6 --- /dev/null +++ b/etc/examples/72-color-moved-4.diff @@ -0,0 +1,8 @@ +diff --git a/file.py b/file.py +index f2f1f5e..9735c3a 100644 +--- a/file.py ++++ b/file.py +@@ -1,2 +1,2 @@ +-class X: pass # • unicode + class Y: pass # • unicode ++class X: pass # • unicode diff --git a/etc/examples/802-color-moved.diff b/etc/examples/802-color-moved.diff new file mode 100644 index 000000000..40cf9c322 --- /dev/null +++ b/etc/examples/802-color-moved.diff @@ -0,0 +1,12 @@ +commit 57e5082 +Author: Caleb Maclennan +Date: Sat Nov 27 01:08:54 2021 +0300 + + Move verses to correct week file + +diff --git a/foo.md b/foo.md +index ba489f0..0ad8245 100644 +--- a/foo.md ++++ b/foo.md +@@ -20,3 +20,99 @@ foo bar ++As I swore in my wrath, 'They shall not enter my rest.'" diff --git a/etc/release.Makefile b/etc/release.Makefile index 79cb8d2e6..012c77fa0 100644 --- a/etc/release.Makefile +++ b/etc/release.Makefile @@ -28,8 +28,6 @@ bump-version: $(BUMP_VERSION_SENTINEL) $(BUMP_VERSION_SENTINEL): @echo Bumping version in Cargo.toml sed -i -E "s,^version = \"$$DELTA_OLD_VERSION\",version = \"$$DELTA_NEW_VERSION\",g" Cargo.toml - make build - make test git add Cargo.toml Cargo.lock git commit -m "Bump version" || true touch $(BUMP_VERSION_SENTINEL) diff --git a/src/features/side_by_side.rs b/src/features/side_by_side.rs index 7f944772d..f335632cf 100644 --- a/src/features/side_by_side.rs +++ b/src/features/side_by_side.rs @@ -14,7 +14,7 @@ use crate::paint::{BgFillMethod, BgShouldFill}; use crate::style::Style; use crate::wrapping::wrap_zero_block; -pub type LineSegments<'a, S> = Vec<(S, &'a str)>; +pub type LineSections<'a, S> = Vec<(S, &'a str)>; pub fn make_feature() -> Vec<(String, OptionValueFunction)> { builtin_feature!([ @@ -111,8 +111,8 @@ pub fn has_long_lines( /// Emit a sequence of minus and plus lines in side-by-side mode. #[allow(clippy::too_many_arguments)] pub fn paint_minus_and_plus_lines_side_by_side<'a>( - syntax_left_right: LeftRight>>, - diff_left_right: LeftRight>>, + syntax_left_right: LeftRight>>, + diff_left_right: LeftRight>>, states_left_right: LeftRight>, line_alignment: Vec<(Option, Option)>, output_buffer: &mut String, @@ -152,8 +152,8 @@ pub fn paint_minus_and_plus_lines_side_by_side<'a>( #[allow(clippy::too_many_arguments)] pub fn paint_zero_lines_side_by_side<'a>( raw_line: &str, - syntax_style_sections: Vec>, - diff_style_sections: Vec>, + syntax_style_sections: Vec>, + diff_style_sections: Vec>, output_buffer: &mut String, config: &Config, line_numbers_data: &mut Option<&mut line_numbers::LineNumbersData>, @@ -206,8 +206,8 @@ pub fn paint_zero_lines_side_by_side<'a>( #[allow(clippy::too_many_arguments)] fn paint_left_panel_minus_line<'a>( line_index: Option, - syntax_style_sections: &[LineSegments<'a, SyntectStyle>], - diff_style_sections: &[LineSegments<'a, Style>], + syntax_style_sections: &[LineSections<'a, SyntectStyle>], + diff_style_sections: &[LineSections<'a, Style>], state: &'a State, line_numbers_data: &mut Option<&mut line_numbers::LineNumbersData>, background_color_extends_to_terminal_width: BgShouldFill, @@ -239,8 +239,8 @@ fn paint_left_panel_minus_line<'a>( #[allow(clippy::too_many_arguments)] fn paint_right_panel_plus_line<'a>( line_index: Option, - syntax_style_sections: &[LineSegments<'a, SyntectStyle>], - diff_style_sections: &[LineSegments<'a, Style>], + syntax_style_sections: &[LineSections<'a, SyntectStyle>], + diff_style_sections: &[LineSections<'a, Style>], state: &'a State, line_numbers_data: &mut Option<&mut line_numbers::LineNumbersData>, background_color_extends_to_terminal_width: BgShouldFill, @@ -273,7 +273,7 @@ fn paint_right_panel_plus_line<'a>( fn get_right_fill_style_for_panel<'a>( line_is_empty: bool, line_index: Option, - diff_style_sections: &[LineSegments<'a, Style>], + diff_style_sections: &[LineSections<'a, Style>], state: &State, panel_side: PanelSide, background_color_extends_to_terminal_width: BgShouldFill, @@ -330,8 +330,8 @@ fn get_right_fill_style_for_panel<'a>( #[allow(clippy::too_many_arguments)] fn paint_minus_or_plus_panel_line<'a>( line_index: Option, - syntax_style_sections: &[LineSegments<'a, SyntectStyle>], - diff_style_sections: &[LineSegments<'a, Style>], + syntax_style_sections: &[LineSections<'a, SyntectStyle>], + diff_style_sections: &[LineSections<'a, Style>], state: &State, line_numbers_data: &mut Option<&mut line_numbers::LineNumbersData>, panel_side: PanelSide, @@ -388,7 +388,7 @@ fn pad_panel_line_to_width<'a>( panel_line: &mut String, panel_line_is_empty: bool, line_index: Option, - diff_style_sections: &[LineSegments<'a, Style>], + diff_style_sections: &[LineSections<'a, Style>], state: &State, panel_side: PanelSide, background_color_extends_to_terminal_width: BgShouldFill, diff --git a/src/paint.rs b/src/paint.rs index fbd0ee15c..cfd453fe6 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -13,7 +13,7 @@ use crate::edits; use crate::features::hyperlinks; use crate::features::line_numbers; use crate::features::side_by_side::ansifill; -use crate::features::side_by_side::{self, available_line_width, LineSegments, PanelSide}; +use crate::features::side_by_side::{self, available_line_width, LineSections, PanelSide}; use crate::minusplus::*; use crate::paint::superimpose_style_sections::superimpose_style_sections; use crate::style::Style; @@ -60,7 +60,7 @@ impl Default for BgShouldFill { #[derive(PartialEq, Debug)] pub enum StyleSectionSpecifier<'l> { Style(Style), - StyleSections(LineSegments<'l, Style>), + StyleSections(LineSections<'l, Style>), } impl<'p> Painter<'p> { @@ -135,9 +135,13 @@ impl<'p> Painter<'p> { } } - // Remove initial -/+ character, and expand tabs as spaces, retaining ANSI sequences. + // Remove initial -/+ character, expand tabs as spaces, retaining ANSI sequences. Terminate with + // newline character. pub fn prepare_raw_line(&self, raw_line: &str) -> String { - ansi::ansi_preserving_slice(&self.expand_tabs(raw_line.graphemes(true)), 1) + format!( + "{}\n", + ansi::ansi_preserving_slice(&self.expand_tabs(raw_line.graphemes(true)), 1), + ) } /// Expand tabs as spaces. @@ -339,8 +343,8 @@ impl<'p> Painter<'p> { /// highlighting styles, and write colored lines to output buffer. #[allow(clippy::too_many_arguments)] pub fn paint_lines<'a>( - syntax_style_sections: Vec>, - diff_style_sections: Vec>, + syntax_style_sections: Vec>, + diff_style_sections: Vec>, states: impl Iterator, output_buffer: &mut String, config: &config::Config, @@ -626,7 +630,7 @@ impl<'p> Painter<'p> { lines: &'a [(String, State)], highlighter: Option<&mut HighlightLines>, config: &config::Config, - ) -> Vec> { + ) -> Vec> { let mut line_sections = Vec::new(); match ( highlighter, @@ -655,8 +659,8 @@ impl<'p> Painter<'p> { plus_lines_and_states: &'a [(String, State)], config: &config::Config, ) -> ( - Vec>, - Vec>, + Vec>, + Vec>, Vec<(Option, Option)>, ) { let (minus_lines, minus_styles): (Vec<&str>, Vec