git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "David Kågedal" <davidk@lysator.liu.se>
To: git@vger.kernel.org
Subject: [PATCH] Added -d and -e options to the "git" script.
Date: Mon, 19 Sep 2005 12:19:36 +0200	[thread overview]
Message-ID: <u5tmzm9bbrb.fsf@lysator.liu.se> (raw)
In-Reply-To: Pine.LNX.4.58.0509181114190.26803@g5.osdl.org

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

  reply	other threads:[~2005-09-19 10:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-18 18:18 Add "--git-dir" flag to git-rev-parse Linus Torvalds
2005-09-19 10:19 ` David Kågedal [this message]
2005-09-19 14:14   ` [PATCH] Added -d and -e options to the "git" script A Large Angry SCM
2005-09-19 14:24     ` David Kågedal
2005-09-19 14:42       ` A Large Angry SCM
2005-09-19 15:08         ` David Kågedal
2005-09-19 14:42   ` Matthias Urlichs

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=u5tmzm9bbrb.fsf@lysator.liu.se \
    --to=davidk@lysator.liu.se \
    --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;
as well as URLs for NNTP newsgroup(s).