mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-12-12 09:10:45 +01:00
batdiff: Check delta version for --hunk-style
This adds compatibility for older `delta` versions.
This commit is contained in:
parent
6f579b1d45
commit
4039859b62
@ -34,6 +34,7 @@ SUPPORTS_DELTA=false
|
|||||||
BAT_VERSION="$(bat_version)"
|
BAT_VERSION="$(bat_version)"
|
||||||
BAT_ARGS=()
|
BAT_ARGS=()
|
||||||
DELTA_ARGS=()
|
DELTA_ARGS=()
|
||||||
|
DELTA_VERSION='unsupported'
|
||||||
GIT_ARGS=()
|
GIT_ARGS=()
|
||||||
|
|
||||||
FILES=()
|
FILES=()
|
||||||
@ -50,6 +51,15 @@ fi
|
|||||||
# Set options based on delta availability.
|
# Set options based on delta availability.
|
||||||
if command -v "$EXECUTABLE_DELTA" &>/dev/null; then
|
if command -v "$EXECUTABLE_DELTA" &>/dev/null; then
|
||||||
SUPPORTS_DELTA=true
|
SUPPORTS_DELTA=true
|
||||||
|
DELTA_VERSION="$("$EXECUTABLE_DELTA" --version | cut -d' ' -f2)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set options based on delta version.
|
||||||
|
# - 0.12 -- Renamed `--hunk-style` to `--hunk-header-decoration-style`.
|
||||||
|
if version_compare "$DELTA_VERSION" -ge "0.12"; then
|
||||||
|
DELTA_ARGS+=("--hunk-header-decoration-style=plain")
|
||||||
|
else
|
||||||
|
DELTA_ARGS+=("--hunk-style=plain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parse arguments.
|
# Parse arguments.
|
||||||
@ -82,8 +92,7 @@ done
|
|||||||
BAT_ARGS+=("--terminal-width=${OPT_TERMINAL_WIDTH}" "--paging=never")
|
BAT_ARGS+=("--terminal-width=${OPT_TERMINAL_WIDTH}" "--paging=never")
|
||||||
DELTA_ARGS+=(
|
DELTA_ARGS+=(
|
||||||
"--width=${OPT_TERMINAL_WIDTH}"
|
"--width=${OPT_TERMINAL_WIDTH}"
|
||||||
"--paging=never"
|
"--paging=never"
|
||||||
"--hunk-header-decoration-style=plain"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if "$OPT_COLOR"; then
|
if "$OPT_COLOR"; then
|
||||||
|
Loading…
Reference in New Issue
Block a user