[RFC/PATCH] git wrapper: add --git-path=<path> and --bare options
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jul 25, 2006, 17:30 UTC
- Message-ID
- <Pine.LNX.4.63.0607251926190.29667@wbgn013.biozentrum.uni-wuerzburg.de>
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