From: Junio C Hamano Date: Mon, 19 Jun 2017 19:38:45 +0000 (-0700) Subject: Merge branch 'jk/consistent-h' X-Git-Tag: v2.14.0-rc0~84 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/50ad8561dee9d479e41586689486cbbb4a742f7b?hp=--cc 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 --- 50ad8561dee9d479e41586689486cbbb4a742f7b diff --cc builtin/diff-files.c index a572da9d51,6be1df684a..c97069a714 --- a/builtin/diff-files.c +++ b/builtin/diff-files.c @@@ -20,9 -20,12 +20,12 @@@ int cmd_diff_files(int argc, const cha 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(); - git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ rev.abbrev = 0; precompose_argv(argc, argv); diff --cc builtin/diff-index.c index f084826a29,02dd35ba45..d59bf6cf5f --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@@ -17,9 -17,12 +17,12 @@@ int cmd_diff_index(int argc, const cha 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(); - git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ rev.abbrev = 0; precompose_argv(argc, argv); diff --cc builtin/diff-tree.c index 1fd06eac4b,773cc254b5..7e15d01f36 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@@ -104,9 -105,12 +104,12 @@@ int cmd_diff_tree(int argc, const char 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(); - git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ opt->abbrev = 0; opt->diff = 1; opt->disable_stdin = 1;