From: David Kågedal Date: Mon, 19 Sep 2005 10:19:36 GMT Subject: [PATCH] Added -d and -e options to the "git" script. Message-ID: In-Reply-To: These flags override the GIT_DIR and EDITOR environment variables. --- This is more generic way to specify GIT_DIR than Linus' suggestion, although it is only targeted at more porcelainish usage of the git driver script. I needed this for the Emacs commands I've been hacking on, since it's hard to set environment variables for single commands without involving /bin/env or a shell. git.sh | 37 +++++++++++++++++++++++++------------ 1 files changed, 25 insertions(+), 12 deletions(-) b9a38ed5a16289f86b353c0bb541e607d35180a9 diff --git a/git.sh b/git.sh --- a/git.sh +++ b/git.sh @@ -2,19 +2,32 @@ cmd= path=$(dirname $0) -case "$#" in -0) ;; -*) cmd="$1" - shift - case "$cmd" in - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "git version @@GIT_VERSION@@" - exit 0 ;; - esac - test -x $path/git-$cmd && exec $path/git-$cmd "$@" ;; -esac -echo "Usage: git COMMAND [OPTIONS] [TARGET]" +while test "$#" -gt 0 +do + case "$1" in + -d) export GIT_DIR + GIT_DIR=$2 + shift + ;; + -e) export EDITOR + EDITOR=$2 + shift + ;; + *) cmd="$1" + shift + case "$cmd" in + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "git version @@GIT_VERSION@@" + exit 0 ;; + esac + test -x $path/git-$cmd && exec $path/git-$cmd "$@" + ;; + esac + shift +done + +echo "Usage: git [GLOBAL OPTIONS] COMMAND [COMMAND OPTIONS]" if [ -n "$cmd" ]; then echo " git command '$cmd' not found: commands are:" else -- David Kågedal