mirror of
https://github.com/ivabus/pantry
synced 2024-11-26 10:25:05 +03:00
fc48863ecf
this prevents our shim from calling pkgx for `git -C . status`, blowing up prompt responsiveness. ref: https://github.com/pkgxdev/pkgx/issues/784
45 lines
906 B
Bash
Executable file
45 lines
906 B
Bash
Executable file
#!/bin/sh
|
||
|
||
set -e
|
||
|
||
find_git_command() {
|
||
for arg in "$@"; do
|
||
if test "$SKIP" = 1; then
|
||
SKIP=0
|
||
continue
|
||
fi
|
||
case $arg in
|
||
-C) SKIP=1; continue;;
|
||
-*);;
|
||
*)
|
||
echo "$arg"
|
||
return # found the command!
|
||
esac
|
||
done
|
||
}
|
||
|
||
libexec="$(cd "$(dirname "$0")/.." && pwd)"/libexec
|
||
|
||
# extract the git subcommand
|
||
cmd=$(find_git_command "$@")
|
||
|
||
_provides() {
|
||
if foo="$(pkgx --provider git-"$cmd")"; then
|
||
echo "$foo"
|
||
else
|
||
# syncing is slow but let’s be sure about it
|
||
pkgx --sync --provider git-"$cmd"
|
||
fi
|
||
}
|
||
|
||
if [ -z "$cmd" ]; then
|
||
exec "$libexec/git" "$@"
|
||
elif [ -x "$libexec/git-$cmd" ] && [ -f "$libexec/git-$cmd" ]; then
|
||
exec "$libexec/git" "$@"
|
||
elif type "git-$cmd" >/dev/null 2>&1; then
|
||
exec "$libexec/git" "$@"
|
||
elif command -v pkgx >/dev/null 2>&1 && pkg=$(_provides); then
|
||
exec pkgx +"$pkg" "$libexec/git" "$@"
|
||
else
|
||
exec "$libexec/git" "$@"
|
||
fi
|