hash-object: add --literally option
[gitweb.git] / builtin / help.c
index f1e236b9124f8b7bfd9aa5e926d525c6f4568268..8343b4027d458d77a720f79d64c9a4c116208f84 100644 (file)
@@ -79,12 +79,11 @@ static const char *get_man_viewer_info(const char *name)
 static int check_emacsclient_version(void)
 {
        struct strbuf buffer = STRBUF_INIT;
-       struct child_process ec_process;
+       struct child_process ec_process = CHILD_PROCESS_INIT;
        const char *argv_ec[] = { "emacsclient", "--version", NULL };
        int version;
 
        /* emacsclient prints its version number on stderr */
-       memset(&ec_process, 0, sizeof(ec_process));
        ec_process.argv = argv_ec;
        ec_process.err = -1;
        ec_process.stdout_to_stderr = 1;
@@ -100,7 +99,7 @@ static int check_emacsclient_version(void)
         */
        finish_command(&ec_process);
 
-       if (prefixcmp(buffer.buf, "emacsclient")) {
+       if (!starts_with(buffer.buf, "emacsclient")) {
                strbuf_release(&buffer);
                return error(_("Failed to parse emacsclient version."));
        }
@@ -258,7 +257,7 @@ static int add_man_viewer_info(const char *var, const char *value)
 
 static int git_help_config(const char *var, const char *value, void *cb)
 {
-       if (!prefixcmp(var, "column."))
+       if (starts_with(var, "column."))
                return git_column_config(var, value, "help", &colopts);
        if (!strcmp(var, "help.format")) {
                if (!value)
@@ -278,7 +277,7 @@ static int git_help_config(const char *var, const char *value, void *cb)
                add_man_viewer(value);
                return 0;
        }
-       if (!prefixcmp(var, "man."))
+       if (starts_with(var, "man."))
                return add_man_viewer_info(var, value);
 
        return git_default_config(var, value, cb);
@@ -288,6 +287,10 @@ static struct cmdnames main_cmds, other_cmds;
 
 static int is_git_command(const char *s)
 {
+       if (is_builtin(s))
+               return 1;
+
+       load_command_list("git-", &main_cmds, &other_cmds);
        return is_in_cmdlist(&main_cmds, s) ||
                is_in_cmdlist(&other_cmds, s);
 }
@@ -306,7 +309,7 @@ static const char *cmd_to_page(const char *git_cmd)
 {
        if (!git_cmd)
                return "git";
-       else if (!prefixcmp(git_cmd, "git"))
+       else if (starts_with(git_cmd, "git"))
                return git_cmd;
        else if (is_git_command(git_cmd))
                return prepend("git-", git_cmd);
@@ -449,7 +452,6 @@ int cmd_help(int argc, const char **argv, const char *prefix)
        int nongit;
        const char *alias;
        enum help_format parsed_help_format;
-       load_command_list("git-", &main_cmds, &other_cmds);
 
        argc = parse_options(argc, argv, prefix, builtin_help_options,
                        builtin_help_usage, 0);
@@ -458,6 +460,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
        if (show_all) {
                git_config(git_help_config, NULL);
                printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
+               load_command_list("git-", &main_cmds, &other_cmds);
                list_commands(colopts, &main_cmds, &other_cmds);
        }