feat: support diff highlight for inline patch diff

This commit is contained in:
Ben Grande 2024-03-19 19:26:55 +01:00
parent 99f184d1fd
commit 1afa166f3e
No known key found for this signature in database
GPG Key ID: 00C64E14F51F9E56
2 changed files with 19 additions and 2 deletions

View File

@ -128,7 +128,7 @@
defaultbranch = main
templatedir = ~/.config/git/template
[interactive]
diffFilter = delta --color-only
diffFilter = git-pager
[mailinfo]
scissors = true
[merge]

View File

@ -1,6 +1,6 @@
#!/bin/sh
## SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
## SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
@ -9,5 +9,22 @@ set -eu
if command -v delta >/dev/null; then
exec delta "$@"
else
: "${DIFF_HIGHLIGHT_SOURCE:=/usr/share/doc/git/contrib/diff-highlight}"
: "${DIFF_HIGHLIGHT_EXEC:=/usr/share/git-core/contrib/diff-highlight}"
## Debian.
if command -v perl &&
test -f "${DIFF_HIGHLIGHT_SOURCE}/DiffHighlight.pm" &&
test -f "${DIFF_HIGHLIGHT_SOURCE}/diff-highlight.perl"
then
exec perl -I "${DIFF_HIGHLIGHT_SOURCE}" -MDiffHighlight -- \
"${DIFF_HIGHLIGHT_SOURCE}/diff-highlight.perl" | less -RS
## Fedora.
elif command -v perl && test -f "${DIFF_HIGHLIGHT_EXEC}"
then
exec "${DIFF_HIGHLIGHT_EXEC}" | less -RS
fi
exec less -RS "$@"
fi