summaryrefslogtreecommitdiff
path: root/builtin/rev-list.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-01 04:38:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-05 02:39:59 (GMT)
commit5a88f97cff0f269f8b2069b17c9da05ee66c98bb (patch)
treec7cb309f1167013a5d292be28c6d5db72b0bbb66 /builtin/rev-list.c
parentf0994fa85dfcbd9854686d7b6de3b05b7952f41c (diff)
downloadgit-5a88f97cff0f269f8b2069b17c9da05ee66c98bb.zip
git-5a88f97cff0f269f8b2069b17c9da05ee66c98bb.tar.gz
git-5a88f97cff0f269f8b2069b17c9da05ee66c98bb.tar.bz2
diff- and log- family: handle "git cmd -h" early
"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. Strictly speaking, they may not need a repository only for parsing "-h", but it is a good discipline to future-proof codepath to ensure that setup_revisions() is called after we know that a repository is there. 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>
Diffstat (limited to 'builtin/rev-list.c')
-rw-r--r--builtin/rev-list.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index bcf77f0..2951e0e 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;