{"thread":{"id":"1506","subject":"[PATCH] clean up git script","startedAt":"2005-08-14T05:16:54Z","lastAt":"2005-08-14T05:16:54Z","messageCount":1,"participants":["Amos Waterland"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"7238","messageId":"20050814051654.GA36848@rossby.metr.ou.edu","threadId":"1506","inReplyTo":null,"subject":"[PATCH] clean up git script","fromName":"Amos Waterland","fromEmail":"apw@rossby.metr.ou.edu","sentAt":"2005-08-14T05:16:54Z","receivedAt":"2005-08-14T05:16:54Z","isPatch":true,"sender":{"key":"apw@debian.org","avatar":null},"body":"Makes git work with a pure POSIX shell (tested with bash --posix and ash).\nRight now git causes ash to choke on the redundant shift on line two.\n\nReduces the number of system calls git makes just to do a usage\nstatement from 22610 to 1122, and the runtime for same from 349ms to\n29ms on my x86 Linux box. \n\nPresents a standard usage statement, and pretty prints the available\ncommands in a form that does not scroll off small terminals.\n\nSigned-off-by: Amos Waterland <apw@rossby.metr.ou.edu>\n\n---\n\n git |   27 +++++++++++++--------------\n 1 files changed, 13 insertions(+), 14 deletions(-)\n\ndiff --git a/git b/git\n--- a/git\n+++ b/git\n@@ -1,19 +1,18 @@\n #!/bin/sh\n+\n cmd=\"$1\"\n-shift\n-if which git-$cmd-script >& /dev/null\n-then\n-\texec git-$cmd-script \"$@\"\n-fi\n+path=$(dirname $0)\n \n-if which git-$cmd >& /dev/null\n-then\n-\texec git-$cmd \"$@\"\n-fi\n+test -x $path/git-$cmd-script && exec $path/git-$cmd-script \"$@\"\n+test -x $path/git-$cmd && exec $path/git-$cmd \"$@\"\n \n-alternatives=($(echo $PATH | tr ':' '\\n' | while read i; do ls $i/git-*-script 2> /dev/null; done))\n+echo \"Usage: git COMMAND [OPTIONS] [TARGET]\"\n+if [ -n \"$cmd\" ]; then\n+    echo \" git command '$cmd' not found: commands are:\"\n+else\n+    echo \" git commands are:\"\n+fi\n \n-echo Git command \"'$cmd'\" not found. Try one of\n-for i in \"${alternatives[@]}\"; do\n-\techo $i | sed 's:^.*/git-:   :' | sed 's:-script$::'\n-done | sort | uniq\n+alternatives=$(cd $path &&\n+               ls git-*-script | sed -e 's/git-//' -e 's/-script//')\n+echo $alternatives | fmt | sed 's/^/  /'\n"}]}