aboutsummaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2009-11-09 09:05:01 -0600
committerJunio C Hamano <gitster@pobox.com>2009-11-10 12:00:21 -0800
commit99caeed05d3e89176d352104a2b70a77aa7e5d81 (patch)
treef65515f8b4302877d661176266cd6bf9a75e5a53 /git.c
parent548d3464dc446db58a8fc8f7a8cc6cfb2d683faa (diff)
downloadgit-99caeed05d3e89176d352104a2b70a77aa7e5d81.tar.gz
git-99caeed05d3e89176d352104a2b70a77aa7e5d81.tar.xz
Let 'git <command> -h' show usage without a git dir
There is no need for "git <command> -h" to depend on being inside a repository. Reported by Gerfried Fuchs through http://bugs.debian.org/462557 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git.c')
-rw-r--r--git.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/git.c b/git.c
index f295561a9..743ee5710 100644
--- a/git.c
+++ b/git.c
@@ -229,21 +229,24 @@ struct cmd_struct {
static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
{
- int status;
+ int status, help;
struct stat st;
const char *prefix;
prefix = NULL;
- if (p->option & RUN_SETUP)
- prefix = setup_git_directory();
-
- if (use_pager == -1 && p->option & RUN_SETUP)
- use_pager = check_pager_config(p->cmd);
- if (use_pager == -1 && p->option & USE_PAGER)
- use_pager = 1;
+ help = argc == 2 && !strcmp(argv[1], "-h");
+ if (!help) {
+ if (p->option & RUN_SETUP)
+ prefix = setup_git_directory();
+
+ if (use_pager == -1 && p->option & RUN_SETUP)
+ use_pager = check_pager_config(p->cmd);
+ if (use_pager == -1 && p->option & USE_PAGER)
+ use_pager = 1;
+ }
commit_pager_choice();
- if (p->option & NEED_WORK_TREE)
+ if (!help && p->option & NEED_WORK_TREE)
setup_work_tree();
trace_argv_printf(argv, "trace: built-in: git");