Git development
 help / color / mirror / Atom feed
* [RFC/PATCH] git wrapper: add --git-path=<path> and --bare options
@ 2006-07-25 17:30 Johannes Schindelin
  2006-07-25 17:43 ` Linus Torvalds
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2006-07-25 17:30 UTC (permalink / raw)
  To: git, junkio


With this, you can say

	git --bare repack -a -d

inside a bare repository, and it will actually work. While at
documenting these options, also document the --paginate option.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
	This is on top of my "allow wrapper options in aliases" patch.

	I hope I did not fsck up the asciidoc formatting; ATM I cannot 
	test that.

	If you agree this is a good approach, should I also move the 
	--version and --exec-path options into handle_options()?

	If you do, I will also make this more user-friendly, i.e.
	it should not crash when saying "git --bare".

 Documentation/git.txt |   12 +++++++++++-
 git.c                 |    9 +++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index ce30581..b5da5f9 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -8,7 +8,8 @@ git - the stupid content tracker
 
 SYNOPSIS
 --------
-'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ARGS]
+'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]
+	[--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]
 
 DESCRIPTION
 -----------
@@ -41,6 +42,15 @@ OPTIONS
 	environment variable. If no path is given 'git' will print
 	the current setting and then exit.
 
+-p|--paginate::
+	Pipe all output into 'less' (or if set, $PAGER).
+
+--git-path=<path>::
+	Set the path to the repository. This can also be controlled by
+	setting the GIT_DIR environment variable.
+
+--bare::
+	Same as --git-path=`pwd`.
 
 FURTHER DOCUMENTATION
 ---------------------
diff --git a/git.c b/git.c
index 8d7c644..e048f54 100644
--- a/git.c
+++ b/git.c
@@ -46,6 +46,15 @@ static int handle_options(const char*** 
 
 		if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
 			setup_pager();
+		} else if (!strcmp(cmd, "--git-dir") && *argc > 1) {
+			setenv("GIT_DIR", (*argv)[1], 1);
+			(*argv)++;
+			(*argc)--;
+		} else if (!strncmp(cmd, "--git-dir=", 10)) {
+			setenv("GIT_DIR", cmd + 10, 1);
+		} else if (!strcmp(cmd, "--bare")) {
+			static char git_dir[1024];
+			setenv("GIT_DIR", getcwd(git_dir, 1024), 1);
 		} else
 			die ("Unknown option: %s", cmd);
 
-- 
1.4.2.rc1.gf725-dirty

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-07-26  7:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-25 17:30 [RFC/PATCH] git wrapper: add --git-path=<path> and --bare options Johannes Schindelin
2006-07-25 17:43 ` Linus Torvalds
2006-07-25 17:52   ` Johannes Schindelin
2006-07-25 18:24     ` [PATCH] " Johannes Schindelin
2006-07-25 21:01       ` Junio C Hamano
2006-07-26  6:18     ` [RFC/PATCH] " Uwe Zeisberger
2006-07-26  7:12       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox