help: change a message to be more precise
[gitweb.git] / builtin / help.c
index e8f79d7af54bce18e8d503dea182146da0fbd456..dbe45c5962890f32a0e0dccff809a33c87c4e32d 100644 (file)
@@ -2,6 +2,7 @@
  * Builtin help command
  */
 #include "cache.h"
+#include "config.h"
 #include "builtin.h"
 #include "exec_cmd.h"
 #include "parse-options.h"
@@ -37,8 +38,10 @@ static int show_all = 0;
 static int show_guides = 0;
 static unsigned int colopts;
 static enum help_format help_format = HELP_FORMAT_NONE;
+static int exclude_guides;
 static struct option builtin_help_options[] = {
        OPT_BOOL('a', "all", &show_all, N_("print all available commands")),
+       OPT_HIDDEN_BOOL(0, "exclude-guides", &exclude_guides, N_("exclude guides")),
        OPT_BOOL('g', "guides", &show_guides, N_("print list of useful guides")),
        OPT_SET_INT('m', "man", &help_format, N_("show man page"), HELP_FORMAT_MAN),
        OPT_SET_INT('w', "web", &help_format, N_("show manual in web browser"),
@@ -426,10 +429,29 @@ static void list_common_guides_help(void)
        putchar('\n');
 }
 
+static const char *check_git_cmd(const char* cmd)
+{
+       char *alias;
+
+       if (is_git_command(cmd))
+               return cmd;
+
+       alias = alias_lookup(cmd);
+       if (alias) {
+               printf_ln(_("'%s' is aliased to '%s'"), cmd, alias);
+               free(alias);
+               exit(0);
+       }
+
+       if (exclude_guides)
+               return help_unknown_cmd(cmd);
+
+       return cmd;
+}
+
 int cmd_help(int argc, const char **argv, const char *prefix)
 {
        int nongit;
-       char *alias;
        enum help_format parsed_help_format;
 
        argc = parse_options(argc, argv, prefix, builtin_help_options,
@@ -469,12 +491,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
        if (help_format == HELP_FORMAT_NONE)
                help_format = parse_help_format(DEFAULT_HELP_FORMAT);
 
-       alias = alias_lookup(argv[0]);
-       if (alias && !is_git_command(argv[0])) {
-               printf_ln(_("`git %s' is aliased to `%s'"), argv[0], alias);
-               free(alias);
-               return 0;
-       }
+       argv[0] = check_git_cmd(argv[0]);
 
        switch (help_format) {
        case HELP_FORMAT_NONE: