summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 548d346)
raw | patch | inline | side by side (parent: 548d346)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Mon, 9 Nov 2009 15:05:01 +0000 (09:05 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 10 Nov 2009 20:00:21 +0000 (12:00 -0800) |
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>
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>
builtin-log.c | patch | blob | history | |
builtin-mv.c | patch | blob | history | |
builtin-read-tree.c | patch | blob | history | |
builtin-reflog.c | patch | blob | history | |
builtin-rerere.c | patch | blob | history | |
git.c | patch | blob | history | |
index-pack.c | patch | blob | history | |
pack-redundant.c | patch | blob | history |
diff --git a/builtin-log.c b/builtin-log.c
index 524850735acd8dcbdf5c5c95332a3c721d8c8483..a0fa30c408090ba4ec5ceefff974a8008ce18aaa 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
if (default_date_mode)
rev->date_mode = parse_date_format(default_date_mode);
+ /*
+ * Check for -h before setup_revisions(), or "git log -h" will
+ * fail when run without a git directory.
+ */
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(builtin_log_usage);
argc = setup_revisions(argc, argv, rev, "HEAD");
if (rev->diffopt.pickaxe || rev->diffopt.filter)
diff --git a/builtin-mv.c b/builtin-mv.c
index 1b20028c67dec2f9954cb107620bd863b4b3a264..f633d81424f5e41cb85ac660dbdc9f4913852673 100644 (file)
--- a/builtin-mv.c
+++ b/builtin-mv.c
git_config(git_default_config, NULL);
- newfd = hold_locked_index(&lock_file, 1);
- if (read_cache() < 0)
- die("index file corrupt");
-
argc = parse_options(argc, argv, prefix, builtin_mv_options,
builtin_mv_usage, 0);
if (--argc < 1)
usage_with_options(builtin_mv_usage, builtin_mv_options);
+ newfd = hold_locked_index(&lock_file, 1);
+ if (read_cache() < 0)
+ die("index file corrupt");
+
source = copy_pathspec(prefix, argv, argc, 0);
modes = xcalloc(argc, sizeof(enum update_mode));
dest_path = copy_pathspec(prefix, argv + argc, 1, 0);
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 14c836b1693317d5d834606e5613d7ceacb3189c..2a3a32cbfe83a0e0366d04a99bb49606f647f594 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
git_config(git_default_config, NULL);
- newfd = hold_locked_index(&lock_file, 1);
-
argc = parse_options(argc, argv, unused_prefix, read_tree_options,
read_tree_usage, 0);
+ newfd = hold_locked_index(&lock_file, 1);
+
prefix_set = opts.prefix ? 1 : 0;
if (1 < opts.merge + opts.reset + prefix_set)
die("Which one? -m, --reset, or --prefix?");
diff --git a/builtin-reflog.c b/builtin-reflog.c
index e23b5ef979d98e5e44693345856a13485695246f..749821078df129cf13de34ebbd40a8cb7a38e00e 100644 (file)
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
int cmd_reflog(int argc, const char **argv, const char *prefix)
{
+ if (argc > 1 && !strcmp(argv[1], "-h"))
+ usage(reflog_usage);
+
/* With no command, we default to showing it. */
if (argc < 2 || *argv[1] == '-')
return cmd_log_reflog(argc, argv, prefix);
diff --git a/builtin-rerere.c b/builtin-rerere.c
index adfb7b5f48597c19c23235b74cf1a0c779985dc6..343d6cde48266d63c0aa6826b973e55b48820745 100644 (file)
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
if (argc < 2)
return rerere();
+ if (!strcmp(argv[1], "-h"))
+ usage(git_rerere_usage);
+
fd = setup_rerere(&merge_rr);
if (fd < 0)
return 0;
index f295561a933c264f869e9b94c948046d3a311be0..743ee57100ac49aca8d90892b1abec5f18eb18c1 100644 (file)
--- a/git.c
+++ b/git.c
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");
diff --git a/index-pack.c b/index-pack.c
index b4f82786592e2e34392191e823d645e17d955fcf..190f372dd81f85d76068b166cc1688487640fdba 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
git_extract_argv0_path(argv[0]);
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(index_pack_usage);
+
/*
* We wish to read the repository's config file if any, and
* for that it is necessary to call setup_git_directory_gently().
diff --git a/pack-redundant.c b/pack-redundant.c
index 69a7ab2e27d39ecabca5c0cc25c4e372caafb46c..21c61dbbe9bd5e2f9770109bc4a9daaf2a2f6cc4 100644 (file)
--- a/pack-redundant.c
+++ b/pack-redundant.c
git_extract_argv0_path(argv[0]);
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(pack_redundant_usage);
+
setup_git_directory();
for (i = 1; i < argc; i++) {