batdiff: Support filtering diffs by directory

This brings parity between using `delta` and `bat --diff`.
Previously, only `delta` supported this use case.
This commit is contained in:
Ethan P. 2023-09-13 11:15:20 -07:00
parent 4039859b62
commit 2e1e768559
No known key found for this signature in database
GPG Key ID: B29B90B1B228FEBC

View File

@ -139,7 +139,8 @@ print_bat_diff() {
# Diff git file.
if "$SUPPORTS_BAT_DIFF"; then
"$EXECUTABLE_BAT" --diff --diff-context="$OPT_CONTEXT" "${files[0]}" "${BAT_ARGS[@]}"
"$EXECUTABLE_GIT" diff "${GIT_ARGS[@]}" --name-only "${files[0]}" \
| xargs "$EXECUTABLE_BAT" --diff --diff-context="$OPT_CONTEXT" "${BAT_ARGS[@]}"
else
"$EXECUTABLE_GIT" diff "${GIT_ARGS[@]}" "${files[0]}" | "$EXECUTABLE_BAT" --language=diff - "${BAT_ARGS[@]}"
fi