Merge branch 'ma/config-page-only-in-list-mode'
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Mar 2018 18:30:09 +0000 (11:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Mar 2018 18:30:09 +0000 (11:30 -0700)
In a way similar to how "git tag" learned to honor the pager
setting only in the list mode, "git config" learned to ignore the
pager setting when it is used for setting values (i.e. when the
purpose of the operation is not to "show").

* ma/config-page-only-in-list-mode:
config: change default of `pager.config` to "on"
config: respect `pager.config` in list/get-mode only
t7006: add tests for how git config paginates

1  2 
git.c
diff --combined git.c
index 96cd734f1282161eebde954f7e638cf8dd8c3516,e5c9b8729d46493744f9af38600a52e4fc3555ed..ceaa58ef40e536f1290cce3ad1223004063e41a6
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -5,11 -5,11 +5,11 @@@
  #include "run-command.h"
  
  const char git_usage_string[] =
 -      "git [--version] [--help] [-C <path>] [-c name=value]\n"
 -      "           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
 -      "           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n"
 -      "           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
 -      "           <command> [<args>]";
 +      N_("git [--version] [--help] [-C <path>] [-c <name>=<value>]\n"
 +         "           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
 +         "           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n"
 +         "           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
 +         "           <command> [<args>]");
  
  const char git_more_info_string[] =
        N_("'git help -a' and 'git help -g' list available subcommands and some\n"
@@@ -92,7 -92,7 +92,7 @@@ static int handle_options(const char **
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--git-dir")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No directory given for --git-dir.\n" );
 +                              fprintf(stderr, _("no directory given for --git-dir\n" ));
                                usage(git_usage_string);
                        }
                        setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--namespace")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No namespace given for --namespace.\n" );
 +                              fprintf(stderr, _("no namespace given for --namespace\n" ));
                                usage(git_usage_string);
                        }
                        setenv(GIT_NAMESPACE_ENVIRONMENT, (*argv)[1], 1);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--work-tree")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No directory given for --work-tree.\n" );
 +                              fprintf(stderr, _("no directory given for --work-tree\n" ));
                                usage(git_usage_string);
                        }
                        setenv(GIT_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--super-prefix")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No prefix given for --super-prefix.\n" );
 +                              fprintf(stderr, _("no prefix given for --super-prefix\n" ));
                                usage(git_usage_string);
                        }
                        setenv(GIT_SUPER_PREFIX_ENVIRONMENT, (*argv)[1], 1);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "-c")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "-c expects a configuration string\n" );
 +                              fprintf(stderr, _("-c expects a configuration string\n" ));
                                usage(git_usage_string);
                        }
                        git_config_push_parameter((*argv)[1]);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "-C")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No directory given for -C.\n" );
 +                              fprintf(stderr, _("no directory given for -C\n" ));
                                usage(git_usage_string);
                        }
                        if ((*argv)[1][0]) {
                                if (chdir((*argv)[1]))
 -                                      die_errno("Cannot change to '%s'", (*argv)[1]);
 +                                      die_errno("cannot change to '%s'", (*argv)[1]);
                                if (envchanged)
                                        *envchanged = 1;
                        }
                        list_builtins();
                        exit(0);
                } else {
 -                      fprintf(stderr, "Unknown option: %s\n", cmd);
 +                      fprintf(stderr, _("unknown option: %s\n"), cmd);
                        usage(git_usage_string);
                }
  
@@@ -247,7 -247,7 +247,7 @@@ static int handle_alias(int *argcp, con
                        if (ret >= 0)   /* normal exit */
                                exit(ret);
  
 -                      die_errno("While expanding alias '%s': '%s'",
 +                      die_errno("while expanding alias '%s': '%s'",
                            alias_command, alias_string + 1);
                }
                count = split_cmdline(alias_string, &new_argv);
                            split_cmdline_strerror(count));
                option_count = handle_options(&new_argv, &count, &envchanged);
                if (envchanged)
 -                      die("alias '%s' changes environment variables\n"
 -                               "You can use '!git' in the alias to do this.",
 +                      die("alias '%s' changes environment variables.\n"
 +                               "You can use '!git' in the alias to do this",
                                 alias_command);
                memmove(new_argv - option_count, new_argv,
                                count * sizeof(char *));
@@@ -389,7 -389,7 +389,7 @@@ static struct cmd_struct commands[] = 
        { "column", cmd_column, RUN_SETUP_GENTLY },
        { "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
        { "commit-tree", cmd_commit_tree, RUN_SETUP },
-       { "config", cmd_config, RUN_SETUP_GENTLY },
+       { "config", cmd_config, RUN_SETUP_GENTLY | DELAY_PAGER_CONFIG },
        { "count-objects", cmd_count_objects, RUN_SETUP },
        { "credential", cmd_credential, RUN_SETUP_GENTLY },
        { "describe", cmd_describe, RUN_SETUP },
@@@ -684,8 -684,8 +684,8 @@@ int cmd_main(int argc, const char **arg
                if (errno != ENOENT)
                        break;
                if (was_alias) {
 -                      fprintf(stderr, "Expansion of alias '%s' failed; "
 -                              "'%s' is not a git command\n",
 +                      fprintf(stderr, _("expansion of alias '%s' failed; "
 +                                        "'%s' is not a git command\n"),
                                cmd, argv[0]);
                        exit(1);
                }
                        break;
        }
  
 -      fprintf(stderr, "Failed to run command '%s': %s\n",
 +      fprintf(stderr, _("failed to run command '%s': %s\n"),
                cmd, strerror(errno));
  
        return 1;