This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/bin/vim-multi-diff-builder

23 lines
444 B
Plaintext
Raw Normal View History

2020-02-12 09:46:01 -06:00
#!/usr/bin/env sh
td="$(mktemp -p "$pdir" -d "tmp_vim_git_multi_diff.XXXXXXXX")"
trap "rm -rf \"$td\"" EXIT
files="$(git diff --name-only "$@")"
for f in $files; do
d="$(dirname "$td/$f")"
rfn="$(basename "$f")"
fn="$rfn._@HEAD"
cfn="$rfn._@DISK"
mkdir -p "$d"
git --no-pager show HEAD:"$f" > "$d/$fn" 2>/dev/null || \
echo "<NO FILE>" > "$d/$fn"
cp "$f" "$d/$cfn"
nvim -d "$d/$fn" "$d/$cfn"
exit 3
done
ls -R "$td"
rm -rf "$td"