diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-06-01 13:38:16 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-01 14:12:27 +0900 |
commit | 29ec62700ad3db6be572c6f3c03a7d0443c86353 (patch) | |
tree | 4c6df3518db70b39a883019cfd010ae30c3af550 | |
parent | 0339965c70d68fd3831c9a5306443c869de3f6a8 (diff) | |
download | git-jc/diff-log-help.tar.gz |
diff- and log- family: handle "git cmd -h" earlyjc/diff-log-help
"git $builtin -h" bypasses the usual repository setup and calls the
cmd_$builtin() function, expecting it to show the help text.
Unfortunately the commands in the log- and the diff- family want to
call into the revisions machinery, which by definition needs to have
a repository already discovered, before they can parse the options.
Handle the "git $builtin -h" special case very early in these
commands to work around potential issues.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/diff-files.c | 3 | ||||
-rw-r--r-- | builtin/diff-index.c | 3 | ||||
-rw-r--r-- | builtin/diff-tree.c | 3 | ||||
-rw-r--r-- | builtin/rev-list.c | 3 |
4 files changed, 12 insertions, 0 deletions
diff --git a/builtin/diff-files.c b/builtin/diff-files.c index 15c61fd8d1..6be1df684a 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); + init_revisions(&rev, prefix); gitmodules_config(); git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ diff --git a/builtin/diff-index.c b/builtin/diff-index.c index 1af373d002..02dd35ba45 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); + init_revisions(&rev, prefix); gitmodules_config(); git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 5ea1c14317..f633b10b08 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -105,6 +105,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); + init_revisions(opt, prefix); gitmodules_config(); git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 718c6059c9..b250c515b1 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; |