2023-10-05 20:52:36 +03:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
find_git_command() {
|
|
|
|
|
for arg in "$@"; do
|
|
|
|
|
case $arg in
|
|
|
|
|
-*);;
|
|
|
|
|
*)
|
2023-10-07 05:57:28 +03:00
|
|
|
|
echo "$arg"
|
2023-10-05 20:52:36 +03:00
|
|
|
|
return # found the command!
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libexec="$(cd "$(dirname "$0")/.." && pwd)"/libexec
|
|
|
|
|
|
|
|
|
|
# extract the git subcommand
|
|
|
|
|
cmd=$(find_git_command "$@")
|
|
|
|
|
|
2023-10-31 17:41:13 +03:00
|
|
|
|
_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
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-05 20:52:36 +03:00
|
|
|
|
if [ -z "$cmd" ]; then
|
|
|
|
|
exec "$libexec/git" "$@"
|
2023-10-07 05:57:28 +03:00
|
|
|
|
elif [ -x "$libexec/git-$cmd" ] && [ -f "$libexec/git-$cmd" ]; then
|
2023-10-05 20:52:36 +03:00
|
|
|
|
exec "$libexec/git" "$@"
|
|
|
|
|
elif type "git-$cmd" >/dev/null 2>&1; then
|
|
|
|
|
exec "$libexec/git" "$@"
|
2023-10-31 17:41:13 +03:00
|
|
|
|
elif command -v pkgx >/dev/null 2>&1 && pkg=$(_provides); then
|
2023-10-07 05:57:28 +03:00
|
|
|
|
exec pkgx +"$pkg" "$libexec/git" "$@"
|
2023-10-05 20:52:36 +03:00
|
|
|
|
else
|
|
|
|
|
exec "$libexec/git" "$@"
|
|
|
|
|
fi
|