packaging: Add contrib installation
[platform/upstream/git.git] / help.c
diff --git a/help.c b/help.c
index 1de9c0d..3c3bdec 100644 (file)
--- a/help.c
+++ b/help.c
@@ -263,6 +263,8 @@ void load_command_list(const char *prefix,
        const char *env_path = getenv("PATH");
        const char *exec_path = git_exec_path();
 
+       load_builtin_commands(prefix, main_cmds);
+
        if (exec_path) {
                list_commands_in_dir(main_cmds, exec_path, prefix);
                QSORT(main_cmds->names, main_cmds->cnt, cmdname_compare);
@@ -375,7 +377,7 @@ void list_cmds_by_config(struct string_list *list)
 {
        const char *cmd_list;
 
-       if (git_config_get_string_const("completion.commands", &cmd_list))
+       if (git_config_get_string_tmp("completion.commands", &cmd_list))
                return;
 
        string_list_sort(list);
@@ -397,10 +399,10 @@ void list_cmds_by_config(struct string_list *list)
        }
 }
 
-void list_common_guides_help(void)
+void list_guides_help(void)
 {
        struct category_description catdesc[] = {
-               { CAT_guide, N_("The common Git guides are:") },
+               { CAT_guide, N_("The Git concept guides are:") },
                { 0, NULL }
        };
        print_cmd_by_category(catdesc, NULL);
@@ -470,12 +472,26 @@ int is_in_cmdlist(struct cmdnames *c, const char *s)
 static int autocorrect;
 static struct cmdnames aliases;
 
+#define AUTOCORRECT_NEVER (-2)
+#define AUTOCORRECT_IMMEDIATELY (-1)
+
 static int git_unknown_cmd_config(const char *var, const char *value, void *cb)
 {
        const char *p;
 
-       if (!strcmp(var, "help.autocorrect"))
-               autocorrect = git_config_int(var,value);
+       if (!strcmp(var, "help.autocorrect")) {
+               if (!value)
+                       return config_error_nonbool(var);
+               if (!strcmp(value, "never")) {
+                       autocorrect = AUTOCORRECT_NEVER;
+               } else if (!strcmp(value, "immediate")) {
+                       autocorrect = AUTOCORRECT_IMMEDIATELY;
+               } else {
+                       int v = git_config_int(var, value);
+                       autocorrect = (v < 0)
+                               ? AUTOCORRECT_IMMEDIATELY : v;
+               }
+       }
        /* Also use aliases for command lookup */
        if (skip_prefix(var, "alias.", &p))
                add_cmdname(&aliases, p, strlen(p));
@@ -523,6 +539,11 @@ const char *help_unknown_cmd(const char *cmd)
 
        read_early_config(git_unknown_cmd_config, NULL);
 
+       if (autocorrect == AUTOCORRECT_NEVER) {
+               fprintf_ln(stderr, _("git: '%s' is not a git command. See 'git --help'."), cmd);
+               exit(1);
+       }
+
        load_command_list("git-", &main_cmds, &other_cmds);
 
        add_cmd_list(&main_cmds, &aliases);
@@ -592,7 +613,7 @@ const char *help_unknown_cmd(const char *cmd)
                           _("WARNING: You called a Git command named '%s', "
                             "which does not exist."),
                           cmd);
-               if (autocorrect < 0)
+               if (autocorrect == AUTOCORRECT_IMMEDIATELY)
                        fprintf_ln(stderr,
                                   _("Continuing under the assumption that "
                                     "you meant '%s'."),
@@ -641,6 +662,7 @@ void get_version_info(struct strbuf *buf, int show_build_options)
                        strbuf_addstr(buf, "no commit associated with this build\n");
                strbuf_addf(buf, "sizeof-long: %d\n", (int)sizeof(long));
                strbuf_addf(buf, "sizeof-size_t: %d\n", (int)sizeof(size_t));
+               strbuf_addf(buf, "shell-path: %s\n", SHELL_PATH);
                /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
        }
 }