Code

split_cmdline: Allow caller to access error string
[git.git] / git.c
diff --git a/git.c b/git.c
index 99f036302a7e6d884369d1d3f4ce428e437cbccd..da56f31a673121f2d45806dd089e633d0aa6a462 100644 (file)
--- a/git.c
+++ b/git.c
@@ -167,6 +167,7 @@ static int handle_alias(int *argcp, const char ***argv)
        alias_string = alias_lookup(alias_command);
        if (alias_string) {
                if (alias_string[0] == '!') {
+                       commit_pager_choice();
                        if (*argcp > 1) {
                                struct strbuf buf;
 
@@ -187,7 +188,8 @@ static int handle_alias(int *argcp, const char ***argv)
                }
                count = split_cmdline(alias_string, &new_argv);
                if (count < 0)
-                       die("Bad alias.%s string", alias_command);
+                       die("Bad alias.%s string: %s", alias_command,
+                           split_cmdline_strerror(count));
                option_count = handle_options(&new_argv, &count, &envchanged);
                if (envchanged)
                        die("alias '%s' changes environment variables\n"
@@ -329,7 +331,7 @@ static void handle_internal_command(int argc, const char **argv)
                { "fsck-objects", cmd_fsck, RUN_SETUP },
                { "gc", cmd_gc, RUN_SETUP },
                { "get-tar-commit-id", cmd_get_tar_commit_id },
-               { "grep", cmd_grep, USE_PAGER },
+               { "grep", cmd_grep },
                { "hash-object", cmd_hash_object },
                { "help", cmd_help },
                { "index-pack", cmd_index_pack },
@@ -432,6 +434,8 @@ static void execv_dashed_external(const char **argv)
        const char *tmp;
        int status;
 
+       commit_pager_choice();
+
        strbuf_addf(&cmd, "git-%s", argv[0]);
 
        /*
@@ -511,12 +515,12 @@ int main(int argc, const char **argv)
        argv++;
        argc--;
        handle_options(&argv, &argc, NULL);
-       commit_pager_choice();
        if (argc > 0) {
                if (!prefixcmp(argv[0], "--"))
                        argv[0] += 2;
        } else {
                /* The user didn't specify a command; give them help */
+               commit_pager_choice();
                printf("usage: %s\n\n", git_usage_string);
                list_common_cmds_help();
                printf("\n%s\n", git_more_info_string);