summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-19 19:38:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-19 19:38:45 (GMT)
commit50ad8561dee9d479e41586689486cbbb4a742f7b (patch)
tree41687648bc7b1674a109fdeb490b9b749f458fde /git.c
parent06959fe0e1f50608ff872be386a7c53d97f885f4 (diff)
parentd691551192ac845747694258ccae9ffeeb6bdd58 (diff)
downloadgit-50ad8561dee9d479e41586689486cbbb4a742f7b.zip
git-50ad8561dee9d479e41586689486cbbb4a742f7b.tar.gz
git-50ad8561dee9d479e41586689486cbbb4a742f7b.tar.bz2
Merge branch 'jk/consistent-h'
"git $cmd -h" for builtin commands calls the implementation of the command (i.e. cmd_$cmd() function) without doing any repository set-up, and the commands that expect RUN_SETUP is done by the Git potty needs to be prepared to show the help text without barfing. * jk/consistent-h: t0012: test "-h" with builtins git: add hidden --list-builtins option version: convert to parse-options diff- and log- family: handle "git cmd -h" early submodule--helper: show usage for "-h" remote-{ext,fd}: print usage message on invalid arguments upload-archive: handle "-h" option early credential: handle invalid arguments earlier
Diffstat (limited to 'git.c')
-rw-r--r--git.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/git.c b/git.c
index 8ff44f0..1b8b7f5 100644
--- a/git.c
+++ b/git.c
@@ -26,6 +26,8 @@ static const char *env_names[] = {
static char *orig_env[4];
static int save_restore_env_balance;
+static void list_builtins(void);
+
static void save_env_before_alias(void)
{
int i;
@@ -232,6 +234,9 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
}
(*argv)++;
(*argc)--;
+ } else if (!strcmp(cmd, "--list-builtins")) {
+ list_builtins();
+ exit(0);
} else {
fprintf(stderr, "Unknown option: %s\n", cmd);
usage(git_usage_string);
@@ -529,6 +534,13 @@ int is_builtin(const char *s)
return !!get_builtin(s);
}
+static void list_builtins(void)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(commands); i++)
+ printf("%s\n", commands[i].cmd);
+}
+
#ifdef STRIP_EXTENSION
static void strip_extension(const char **argv)
{