From 5a88f97cff0f269f8b2069b17c9da05ee66c98bb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 1 Jun 2017 13:38:16 +0900 Subject: 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 --- builtin/diff-files.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin/diff-files.c') 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 */ -- cgit v1.2.3