From: Amos Waterland <apw@rossby.metr.ou.edu>
To: git@vger.kernel.org
Subject: [PATCH] clean up git script
Date: Sun, 14 Aug 2005 00:16:54 -0500 [thread overview]
Message-ID: <20050814051654.GA36848@rossby.metr.ou.edu> (raw)
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.
Signed-off-by: Amos Waterland <apw@rossby.metr.ou.edu>
---
git | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/git b/git
--- a/git
+++ b/git
@@ -1,19 +1,18 @@
#!/bin/sh
+
cmd="$1"
-shift
-if which git-$cmd-script >& /dev/null
-then
- exec git-$cmd-script "$@"
-fi
+path=$(dirname $0)
-if which git-$cmd >& /dev/null
-then
- exec git-$cmd "$@"
-fi
+test -x $path/git-$cmd-script && exec $path/git-$cmd-script "$@"
+test -x $path/git-$cmd && exec $path/git-$cmd "$@"
-alternatives=($(echo $PATH | tr ':' '\n' | while read i; do ls $i/git-*-script 2> /dev/null; done))
+echo "Usage: git COMMAND [OPTIONS] [TARGET]"
+if [ -n "$cmd" ]; then
+ echo " git command '$cmd' not found: commands are:"
+else
+ echo " git commands are:"
+fi
-echo Git command "'$cmd'" not found. Try one of
-for i in "${alternatives[@]}"; do
- echo $i | sed 's:^.*/git-: :' | sed 's:-script$::'
-done | sort | uniq
+alternatives=$(cd $path &&
+ ls git-*-script | sed -e 's/git-//' -e 's/-script//')
+echo $alternatives | fmt | sed 's/^/ /'
reply other threads:[~2005-08-14 5:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050814051654.GA36848@rossby.metr.ou.edu \
--to=apw@rossby.metr.ou.edu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox