Merge branch 'jk/pager-with-external-command'
authorJunio C Hamano <gitster@pobox.com>
Mon, 29 Aug 2011 04:19:25 +0000 (21:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Aug 2011 04:19:25 +0000 (21:19 -0700)
* jk/pager-with-external-command:
support pager.* for external commands

1  2 
git.c
diff --combined git.c
index b660e36660a1fa836a7d0f71a6443bb0b530d644,bb5205e4dd1dfcacc9a02cb53b48d7b7548391c2..8e34903a65c8775b19b993d3e9ddf47c23d5254e
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -7,8 -7,8 +7,8 @@@
  
  const char git_usage_string[] =
        "git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
 -      "           [-p|--paginate|--no-pager] [--no-replace-objects]\n"
 -      "           [--bare] [--git-dir=<path>] [--work-tree=<path>]\n"
 +      "           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]\n"
 +      "           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
        "           [-c name=value] [--help]\n"
        "           <command> [<args>]";
  
@@@ -126,20 -126,6 +126,20 @@@ static int handle_options(const char **
                        setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
                        if (envchanged)
                                *envchanged = 1;
 +              } else if (!strcmp(cmd, "--namespace")) {
 +                      if (*argc < 2) {
 +                              fprintf(stderr, "No namespace given for --namespace.\n" );
 +                              usage(git_usage_string);
 +                      }
 +                      setenv(GIT_NAMESPACE_ENVIRONMENT, (*argv)[1], 1);
 +                      if (envchanged)
 +                              *envchanged = 1;
 +                      (*argv)++;
 +                      (*argc)--;
 +              } else if (!prefixcmp(cmd, "--namespace=")) {
 +                      setenv(GIT_NAMESPACE_ENVIRONMENT, cmd + 12, 1);
 +                      if (envchanged)
 +                              *envchanged = 1;
                } else if (!strcmp(cmd, "--work-tree")) {
                        if (*argc < 2) {
                                fprintf(stderr, "No directory given for --work-tree.\n" );
@@@ -197,6 -183,8 +197,6 @@@ static int handle_alias(int *argcp, con
                if (alias_string[0] == '!') {
                        const char **alias_argv;
                        int argc = *argcp, i;
 -                      struct strbuf sb = STRBUF_INIT;
 -                      const char *env[2];
  
                        commit_pager_choice();
  
                                alias_argv[i] = (*argv)[i];
                        alias_argv[argc] = NULL;
  
 -                      strbuf_addstr(&sb, "GIT_PREFIX=");
 -                      if (subdir)
 -                              strbuf_addstr(&sb, subdir);
 -                      env[0] = sb.buf;
 -                      env[1] = NULL;
 -                      ret = run_command_v_opt_cd_env(alias_argv, RUN_USING_SHELL, NULL, env);
 -                      strbuf_release(&sb);
 +                      ret = run_command_v_opt(alias_argv, RUN_USING_SHELL);
                        if (ret >= 0)   /* normal exit */
                                exit(ret);
  
@@@ -334,7 -328,7 +334,7 @@@ static void handle_internal_command(in
                { "annotate", cmd_annotate, RUN_SETUP },
                { "apply", cmd_apply, RUN_SETUP_GENTLY },
                { "archive", cmd_archive },
 -              { "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
 +              { "bisect--helper", cmd_bisect__helper, RUN_SETUP },
                { "blame", cmd_blame, RUN_SETUP },
                { "branch", cmd_branch, RUN_SETUP },
                { "bundle", cmd_bundle, RUN_SETUP_GENTLY },
@@@ -473,6 -467,8 +473,8 @@@ static void execv_dashed_external(cons
        const char *tmp;
        int status;
  
+       if (use_pager == -1)
+               use_pager = check_pager_config(argv[0]);
        commit_pager_choice();
  
        strbuf_addf(&cmd, "git-%s", argv[0]);