summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorRalf Thielow <ralf.thielow@gmail.com>2016-08-26 19:58:36 +0200
committerJunio C Hamano <gitster@pobox.com>2016-08-30 16:09:41 -0700
commit2c6b6d9f7d8a26b6ae6493584cc3d2a3cbae7358 (patch)
tree663be86da2e4ab3e2c57a13039c2a541540f7462 /git.c
parentaf74128f4a447678daae4d59069fba8a0c797210 (diff)
downloadgit-2c6b6d9f7d8a26b6ae6493584cc3d2a3cbae7358.tar.gz
help: make option --help open man pages only for Git commandsrt/help-unknown
If option --help is passed to a Git command, we try to open the man page of that command. However, we do it for both commands and concepts. Make sure it is an actual command. This makes "git <concept> --help" not working anymore, while "git help <concept>" still works. Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git.c')
-rw-r--r--git.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/git.c b/git.c
index 968a8a4645..6ade0bc938 100644
--- a/git.c
+++ b/git.c
@@ -522,21 +522,34 @@ static void strip_extension(const char **argv)
static void handle_builtin(int argc, const char **argv)
{
+ struct argv_array args = ARGV_ARRAY_INIT;
const char *cmd;
struct cmd_struct *builtin;
strip_extension(argv);
cmd = argv[0];
- /* Turn "git cmd --help" into "git help cmd" */
+ /* Turn "git cmd --help" into "git help --exclude-guides cmd" */
if (argc > 1 && !strcmp(argv[1], "--help")) {
+ int i;
+
argv[1] = argv[0];
argv[0] = cmd = "help";
+
+ for (i = 0; i < argc; i++) {
+ argv_array_push(&args, argv[i]);
+ if (!i)
+ argv_array_push(&args, "--exclude-guides");
+ }
+
+ argc++;
+ argv = args.argv;
}
builtin = get_builtin(cmd);
if (builtin)
exit(run_builtin(builtin, argc, argv));
+ argv_array_clear(&args);
}
static void execv_dashed_external(const char **argv)