mirror of
https://github.com/git/git.git
synced 2024-11-17 06:25:13 +01:00
b0c6f8d767
Makes git work with a pure POSIX shell (tested with bash --posix and ash). Right now git causes ash to choke on the redundant shift on line two. Reduces the number of system calls git makes just to do a usage statement from 22610 to 1122, and the runtime for same from 349ms to 29ms on my x86 Linux box. Presents a standard usage statement, and pretty prints the available commands in a form that does not scroll off small terminals. [jc: while shifting when $# was zero was a bug, the original patch failed to shift when it needs to, which I fixed up.] Signed-off-by: Amos Waterland <apw@rossby.metr.ou.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
22 lines
493 B
Bash
Executable file
22 lines
493 B
Bash
Executable file
#!/bin/sh
|
|
|
|
cmd=
|
|
path=$(dirname $0)
|
|
case "$#" in
|
|
0) ;;
|
|
*) cmd="$1"
|
|
shift
|
|
test -x $path/git-$cmd-script && exec $path/git-$cmd-script "$@"
|
|
test -x $path/git-$cmd && exec $path/git-$cmd "$@" ;;
|
|
esac
|
|
|
|
echo "Usage: git COMMAND [OPTIONS] [TARGET]"
|
|
if [ -n "$cmd" ]; then
|
|
echo " git command '$cmd' not found: commands are:"
|
|
else
|
|
echo " git commands are:"
|
|
fi
|
|
|
|
alternatives=$(cd $path &&
|
|
ls git-*-script | sed -e 's/git-//' -e 's/-script//')
|
|
echo $alternatives | fmt | sed 's/^/ /'
|