git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Added -d and -e options to the "git" script.

From
David Kågedal <davidk@lysator.liu.se>
Date
Sep 19, 2005, 10:19 UTC
Message-ID
<u5tmzm9bbrb.fsf@lysator.liu.se>
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
Previous: Linus TorvaldsNext: A Large Angry SCM
Message 2 of 7 in “Add "--git-dir" flag to git-rev-parse”
  1. Linus TorvaldsSep 18, 2005
  2. Added -d and -e options to the "git" script.David Kågedal, Sep 19, 2005
  3. A Large Angry SCMSep 19, 2005
  4. David KågedalSep 19, 2005
  5. A Large Angry SCMSep 19, 2005
  6. David KågedalSep 19, 2005
  7. Matthias UrlichsSep 19, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.