From 87269b4973e5c71d3a7b3b9387a0e47e97da5e19 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Sat, 17 Feb 2018 12:29:48 -0600 Subject: [PATCH] .gitconfig: Use `diff-highlight` contrib script as diff-filter - bin/diff-filter: Wrapper around calling the Git `diff-highlight` contrib script. This will degrade gracefully if `diff-highlight` script cannot be found in standard locations. - bin/diff-pager: Wrapper around calling new `diff-filter | $PAGER`. This can be used via `git config core.pager` or any other pager-like places which want to format git-patch output. - .gitconfig: - core.pager: use new `diff-pager` wrapper script. - interactive.diffFilter: use new `diff-filter` wrapper script. This lets `git add -i ...` use the same shared diff-filter. - color.diff-highlight: Tweak colors so that "normal" colors have a normal [non-colored] foreground color, and "highlight" colors can be simply "red bold" and "green bold" respectively. This eliminates visual clutter from the colored diff display, so that the diff output is less noise [for line-pairs which `diff-highlight` can process]. --- .gitconfig | 12 ++++++++---- bin/diff-filter | 14 ++++++++++++++ bin/diff-pager | 2 ++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100755 bin/diff-filter create mode 100755 bin/diff-pager diff --git a/.gitconfig b/.gitconfig index ef10054..3a5ef17 100644 --- a/.gitconfig +++ b/.gitconfig @@ -41,6 +41,10 @@ logallrefupdates = true whitespace = space-before-tab, trailing-space excludesfile = ~/.gitignore_global + pager = diff-pager + +[interactive] + diffFilter = diff-filter [diff] renames = copies @@ -77,10 +81,10 @@ untracked = blue bold [color "diff-highlight"] - oldNormal = red bold - oldHighlight = red bold 52 - newNormal = green bold - newHighlight = green bold 22 + oldNormal = nobold + oldHighlight = red bold + newNormal = nobold + newHighlight = green bold [push] default = matching diff --git a/bin/diff-filter b/bin/diff-filter new file mode 100755 index 0000000..dc83358 --- /dev/null +++ b/bin/diff-filter @@ -0,0 +1,14 @@ +#!/bin/sh +# Filter script for git-diff patch output + +# Use `diff-highlight` if available +# Look for script in several expected locations +for f in /usr/local/share/git-core/contrib/diff-highlight/diff-highlight \ + /usr/share/git-core/contrib/diff-highlight/diff-highlight +do + test -x $f && \ + tee | $f && \ + exit 0 +done +# Else, degrade gracefully +tee diff --git a/bin/diff-pager b/bin/diff-pager new file mode 100755 index 0000000..c21d718 --- /dev/null +++ b/bin/diff-pager @@ -0,0 +1,2 @@ +#!/bin/sh +tee | diff-filter | $PAGER -- 2.47.1