Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-19 22:38:45 +0300
committerJunio C Hamano <gitster@pobox.com>2017-06-19 22:38:45 +0300
commit50ad8561dee9d479e41586689486cbbb4a742f7b (patch)
tree41687648bc7b1674a109fdeb490b9b749f458fde /builtin
parent06959fe0e1f50608ff872be386a7c53d97f885f4 (diff)
parentd691551192ac845747694258ccae9ffeeb6bdd58 (diff)
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 'builtin')
-rw-r--r--builtin/credential.c4
-rw-r--r--builtin/diff-files.c3
-rw-r--r--builtin/diff-index.c3
-rw-r--r--builtin/diff-tree.c3
-rw-r--r--builtin/remote-ext.c5
-rw-r--r--builtin/remote-fd.c5
-rw-r--r--builtin/rev-list.c3
-rw-r--r--builtin/submodule--helper.c5
-rw-r--r--builtin/upload-archive.c5
9 files changed, 28 insertions, 8 deletions
diff --git a/builtin/credential.c b/builtin/credential.c
index 0412fa00f0c..879acfbcda7 100644
--- a/builtin/credential.c
+++ b/builtin/credential.c
@@ -10,9 +10,9 @@ int cmd_credential(int argc, const char **argv, const char *prefix)
const char *op;
struct credential c = CREDENTIAL_INIT;
- op = argv[1];
- if (!op)
+ if (argc != 2 || !strcmp(argv[1], "-h"))
usage(usage_msg);
+ op = argv[1];
if (credential_read(&c, stdin) < 0)
die("unable to read credential from stdin");
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index a572da9d515..c97069a714e 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -20,6 +20,9 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
int result;
unsigned options = 0;
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(diff_files_usage);
+
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
init_revisions(&rev, prefix);
gitmodules_config();
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index f084826a293..d59bf6cf5f8 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -17,6 +17,9 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
int i;
int result;
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(diff_cache_usage);
+
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
init_revisions(&rev, prefix);
gitmodules_config();
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 1fd06eac4b9..7e15d01f363 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -104,6 +104,9 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
struct setup_revision_opt s_r_opt;
int read_stdin = 0;
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(diff_tree_usage);
+
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
init_revisions(opt, prefix);
gitmodules_config();
diff --git a/builtin/remote-ext.c b/builtin/remote-ext.c
index 11b48bfb411..bfb21ba7d21 100644
--- a/builtin/remote-ext.c
+++ b/builtin/remote-ext.c
@@ -3,6 +3,9 @@
#include "run-command.h"
#include "pkt-line.h"
+static const char usage_msg[] =
+ "git remote-ext <remote> <url>";
+
/*
* URL syntax:
* 'command [arg1 [arg2 [...]]]' Invoke command with given arguments.
@@ -193,7 +196,7 @@ static int command_loop(const char *child)
int cmd_remote_ext(int argc, const char **argv, const char *prefix)
{
if (argc != 3)
- die("Expected two arguments");
+ usage(usage_msg);
return command_loop(argv[2]);
}
diff --git a/builtin/remote-fd.c b/builtin/remote-fd.c
index 08d7121b6d1..91dfe07e06a 100644
--- a/builtin/remote-fd.c
+++ b/builtin/remote-fd.c
@@ -1,6 +1,9 @@
#include "builtin.h"
#include "transport.h"
+static const char usage_msg[] =
+ "git remote-fd <remote> <url>";
+
/*
* URL syntax:
* 'fd::<inoutfd>[/<anything>]' Read/write socket pair
@@ -57,7 +60,7 @@ int cmd_remote_fd(int argc, const char **argv, const char *prefix)
char *end;
if (argc != 3)
- die("Expected two arguments");
+ usage(usage_msg);
input_fd = (int)strtoul(argv[2], &end, 10);
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 718c6059c9f..b250c515b1a 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -277,6 +277,9 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
int use_bitmap_index = 0;
const char *show_progress = NULL;
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(rev_list_usage);
+
git_config(git_default_config, NULL);
init_revisions(&revs, prefix);
revs.abbrev = DEFAULT_ABBREV;
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 8cc648d85b5..1b4d2b34676 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1221,9 +1221,8 @@ static struct cmd_struct commands[] = {
int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
{
int i;
- if (argc < 2)
- die(_("submodule--helper subcommand must be "
- "called with a subcommand"));
+ if (argc < 2 || !strcmp(argv[1], "-h"))
+ usage("git submodule--helper <command>");
for (i = 0; i < ARRAY_SIZE(commands); i++) {
if (!strcmp(argv[1], commands[i].cmd)) {
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index cde06977b78..84532ae9a93 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -22,7 +22,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
struct argv_array sent_argv = ARGV_ARRAY_INIT;
const char *arg_cmd = "argument ";
- if (argc != 2)
+ if (argc != 2 || !strcmp(argv[1], "-h"))
usage(upload_archive_usage);
if (!enter_repo(argv[1], 0))
@@ -76,6 +76,9 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
{
struct child_process writer = { argv };
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(upload_archive_usage);
+
/*
* Set up sideband subprocess.
*