Merge branch 'ma/branch-list-paginate'
authorJunio C Hamano <gitster@pobox.com>
Tue, 28 Nov 2017 04:41:49 +0000 (13:41 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Nov 2017 04:41:50 +0000 (13:41 +0900)
"git branch --list" learned to show its output through the pager by
default when the output is going to a terminal, which is controlled
by the pager.branch configuration variable. This is similar to a
recent change to "git tag --list".

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

1  2 
Documentation/git-branch.txt
builtin/branch.c
git.c
t/t7006-pager.sh
index d6587c5e96f4dbcdb4176d9dd5f6a992c0e83f3b,ef187ba7cfec284ef472f76462eb655c831ee0d6..520c53b5e8bd3792c349db1895fa2e5608ca0a08
@@@ -18,7 -18,6 +18,7 @@@ SYNOPSI
  'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
  'git branch' --unset-upstream [<branchname>]
  'git branch' (-m | -M) [<oldbranch>] <newbranch>
 +'git branch' (-c | -C) [<oldbranch>] <newbranch>
  'git branch' (-d | -D) [-r] <branchname>...
  'git branch' --edit-description [<branchname>]
  
@@@ -65,10 -64,6 +65,10 @@@ If <oldbranch> had a corresponding refl
  renaming. If <newbranch> exists, -M must be used to force the rename
  to happen.
  
 +The `-c` and `-C` options have the exact same semantics as `-m` and
 +`-M`, except instead of the branch being renamed it along with its
 +config and reflog will be copied to a new name.
 +
  With a `-d` or `-D` option, `<branchname>` will be deleted.  You may
  specify more than one branch for deletion.  If the branch currently
  has a reflog then the reflog will also be deleted.
@@@ -97,19 -92,19 +97,19 @@@ OPTION
        all changes made to the branch ref, enabling use of date
        based sha1 expressions such as "<branchname>@\{yesterday}".
        Note that in non-bare repositories, reflogs are usually
 -      enabled by default by the `core.logallrefupdates` config option.
 +      enabled by default by the `core.logAllRefUpdates` config option.
        The negated form `--no-create-reflog` only overrides an earlier
        `--create-reflog`, but currently does not negate the setting of
 -      `core.logallrefupdates`.
 +      `core.logAllRefUpdates`.
  
  -f::
  --force::
 -      Reset <branchname> to <startpoint> if <branchname> exists
 -      already. Without `-f` 'git branch' refuses to change an existing branch.
 +      Reset <branchname> to <startpoint>, even if <branchname> exists
 +      already. Without `-f`, 'git branch' refuses to change an existing branch.
        In combination with `-d` (or `--delete`), allow deleting the
        branch irrespective of its merged status. In combination with
        `-m` (or `--move`), allow renaming the branch even if the new
 -      branch name already exists.
 +      branch name already exists, the same applies for `-c` (or `--copy`).
  
  -m::
  --move::
  -M::
        Shortcut for `--move --force`.
  
 +-c::
 +--copy::
 +      Copy a branch and the corresponding reflog.
 +
 +-C::
 +      Shortcut for `--copy --force`.
 +
  --color[=<when>]::
        Color branches to highlight current, local, and
        remote-tracking branches.
@@@ -207,8 -195,10 +207,8 @@@ start-point is either a local or remote
        branch.autoSetupMerge configuration variable is true.
  
  --set-upstream::
 -      If specified branch does not exist yet or if `--force` has been
 -      given, acts exactly like `--track`. Otherwise sets up configuration
 -      like `--track` would when creating the branch, except that where
 -      branch points to is not changed.
 +      As this option had confusing syntax, it is no longer supported.
 +      Please use `--track` or `--set-upstream-to` instead.
  
  -u <upstream>::
  --set-upstream-to=<upstream>::
        Only list branches of the given object.
  
  --format <format>::
 -      A string that interpolates `%(fieldname)` from the object
 -      pointed at by a ref being shown.  The format is the same as
 +      A string that interpolates `%(fieldname)` from a branch ref being shown
 +      and the object it points at.  The format is the same as
        that of linkgit:git-for-each-ref[1].
  
+ CONFIGURATION
+ -------------
+ `pager.branch` is only respected when listing branches, i.e., when
+ `--list` is used or implied. The default is to use a pager.
+ See linkgit:git-config[1].
  Examples
  --------
  
diff --combined builtin/branch.c
index 5fc57cdc982f86d6e449d8358004c476707d909c,39fa99bba74d8e9b2528c9c4267d94a88ccc748c..af95ad2192004ad3a712c15f1e50356daadb7c86
@@@ -28,7 -28,6 +28,7 @@@ static const char * const builtin_branc
        N_("git branch [<options>] [-l] [-f] <branch-name> [<start-point>]"),
        N_("git branch [<options>] [-r] (-d | -D) <branch-name>..."),
        N_("git branch [<options>] (-m | -M) [<old-branch>] <new-branch>"),
 +      N_("git branch [<options>] (-c | -C) [<old-branch>] <new-branch>"),
        N_("git branch [<options>] [-r | -a] [--points-at]"),
        N_("git branch [<options>] [-r | -a] [--format]"),
        NULL
@@@ -125,7 -124,7 +125,7 @@@ static int branch_merged(int kind, cons
                if (upstream &&
                    (reference_name = reference_name_to_free =
                     resolve_refdup(upstream, RESOLVE_REF_READING,
 -                                  oid.hash, NULL)) != NULL)
 +                                  &oid, NULL)) != NULL)
                        reference_rev = lookup_commit_reference(&oid);
        }
        if (!reference_rev)
@@@ -217,7 -216,7 +217,7 @@@ static int delete_branches(int argc, co
                if (!head_rev)
                        die(_("Couldn't look up commit object for HEAD"));
        }
 -      for (i = 0; i < argc; i++, strbuf_release(&bname)) {
 +      for (i = 0; i < argc; i++, strbuf_reset(&bname)) {
                char *target = NULL;
                int flags = 0;
  
                                        RESOLVE_REF_READING
                                        | RESOLVE_REF_NO_RECURSE
                                        | RESOLVE_REF_ALLOW_BAD_NAME,
 -                                      oid.hash, &flags);
 +                                      &oid, &flags);
                if (!target) {
                        error(remote_branch
                              ? _("remote-tracking branch '%s' not found.")
                        goto next;
                }
  
 -              if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : oid.hash,
 -                             REF_NODEREF)) {
 +              if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : &oid,
 +                             REF_NO_DEREF)) {
                        error(remote_branch
                              ? _("Error deleting remote-tracking branch '%s'")
                              : _("Error deleting branch '%s'"),
        }
  
        free(name);
 +      strbuf_release(&bname);
  
 -      return(ret);
 +      return ret;
  }
  
  static int calc_maxwidth(struct ref_array *refs, int remote_bonus)
@@@ -354,7 -352,7 +354,7 @@@ static char *build_format(struct ref_fi
                        strbuf_addf(&obname, "%%(objectname:short=%d)", filter->abbrev);
  
                strbuf_addf(&local, "%%(align:%d,left)%%(refname:lstrip=2)%%(end)", maxwidth);
 -              strbuf_addf(&local, "%s", branch_get_color(BRANCH_COLOR_RESET));
 +              strbuf_addstr(&local, branch_get_color(BRANCH_COLOR_RESET));
                strbuf_addf(&local, " %s ", obname.buf);
  
                if (filter->verbose > 1)
        return strbuf_detach(&fmt, NULL);
  }
  
 -static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sorting, const char *format)
 +static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sorting, struct ref_format *format)
  {
        int i;
        struct ref_array array;
        if (filter->verbose)
                maxwidth = calc_maxwidth(&array, strlen(remote_prefix));
  
 -      if (!format)
 -              format = to_free = build_format(filter, maxwidth, remote_prefix);
 -      verify_ref_format(format);
 +      if (!format->format)
 +              format->format = to_free = build_format(filter, maxwidth, remote_prefix);
 +      format->use_color = branch_use_color;
 +
 +      if (verify_ref_format(format))
 +              die(_("unable to parse format string"));
  
        ref_array_sort(sorting, &array);
  
        for (i = 0; i < array.nr; i++) {
 -              format_ref_array_item(array.items[i], format, 0, &out);
 +              format_ref_array_item(array.items[i], format, &out);
                if (column_active(colopts)) {
                        assert(!filter->verbose && "--column and --verbose are incompatible");
                         /* format to a string_list to let print_columns() do its job */
@@@ -458,18 -453,15 +458,18 @@@ static void reject_rebase_or_bisect_bra
        free_worktrees(worktrees);
  }
  
 -static void rename_branch(const char *oldname, const char *newname, int force)
 +static void copy_or_rename_branch(const char *oldname, const char *newname, int copy, int force)
  {
        struct strbuf oldref = STRBUF_INIT, newref = STRBUF_INIT, logmsg = STRBUF_INIT;
        struct strbuf oldsection = STRBUF_INIT, newsection = STRBUF_INIT;
        int recovery = 0;
 -      int clobber_head_ok;
  
 -      if (!oldname)
 -              die(_("cannot rename the current branch while not on any."));
 +      if (!oldname) {
 +              if (copy)
 +                      die(_("cannot copy the current branch while not on any."));
 +              else
 +                      die(_("cannot rename the current branch while not on any."));
 +      }
  
        if (strbuf_check_branch_ref(&oldref, oldname)) {
                /*
         * A command like "git branch -M currentbranch currentbranch" cannot
         * cause the worktree to become inconsistent with HEAD, so allow it.
         */
 -      clobber_head_ok = !strcmp(oldname, newname);
 -
 -      validate_new_branchname(newname, &newref, force, clobber_head_ok);
 +      if (!strcmp(oldname, newname))
 +              validate_branchname(newname, &newref);
 +      else
 +              validate_new_branchname(newname, &newref, force);
  
        reject_rebase_or_bisect_branch(oldref.buf);
  
 -      strbuf_addf(&logmsg, "Branch: renamed %s to %s",
 -               oldref.buf, newref.buf);
 +      if (copy)
 +              strbuf_addf(&logmsg, "Branch: copied %s to %s",
 +                          oldref.buf, newref.buf);
 +      else
 +              strbuf_addf(&logmsg, "Branch: renamed %s to %s",
 +                          oldref.buf, newref.buf);
  
 -      if (rename_ref(oldref.buf, newref.buf, logmsg.buf))
 +      if (!copy && rename_ref(oldref.buf, newref.buf, logmsg.buf))
                die(_("Branch rename failed"));
 +      if (copy && copy_existing_ref(oldref.buf, newref.buf, logmsg.buf))
 +              die(_("Branch copy failed"));
  
 -      if (recovery)
 -              warning(_("Renamed a misnamed branch '%s' away"), oldref.buf + 11);
 +      if (recovery) {
 +              if (copy)
 +                      warning(_("Copied a misnamed branch '%s' away"),
 +                              oldref.buf + 11);
 +              else
 +                      warning(_("Renamed a misnamed branch '%s' away"),
 +                              oldref.buf + 11);
 +      }
  
 -      if (replace_each_worktree_head_symref(oldref.buf, newref.buf, logmsg.buf))
 +      if (!copy &&
 +          replace_each_worktree_head_symref(oldref.buf, newref.buf, logmsg.buf))
                die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
  
        strbuf_release(&logmsg);
        strbuf_release(&oldref);
        strbuf_addf(&newsection, "branch.%s", newref.buf + 11);
        strbuf_release(&newref);
 -      if (git_config_rename_section(oldsection.buf, newsection.buf) < 0)
 +      if (!copy && git_config_rename_section(oldsection.buf, newsection.buf) < 0)
                die(_("Branch is renamed, but update of config-file failed"));
 +      if (copy && strcmp(oldname, newname) && git_config_copy_section(oldsection.buf, newsection.buf) < 0)
 +              die(_("Branch is copied, but update of config-file failed"));
        strbuf_release(&oldsection);
        strbuf_release(&newsection);
  }
@@@ -565,7 -541,7 +565,7 @@@ static int edit_branch_description(cons
  
  int cmd_branch(int argc, const char **argv, const char *prefix)
  {
 -      int delete = 0, rename = 0, force = 0, list = 0;
 +      int delete = 0, rename = 0, copy = 0, force = 0, list = 0;
        int reflog = 0, edit_description = 0;
        int quiet = 0, unset_upstream = 0;
        const char *new_upstream = NULL;
        struct ref_filter filter;
        int icase = 0;
        static struct ref_sorting *sorting = NULL, **sorting_tail = &sorting;
 -      const char *format = NULL;
 +      struct ref_format format = REF_FORMAT_INIT;
  
        struct option options[] = {
                OPT_GROUP(N_("Generic options")),
                OPT__QUIET(&quiet, N_("suppress informational messages")),
                OPT_SET_INT('t', "track",  &track, N_("set up tracking mode (see git-pull(1))"),
                        BRANCH_TRACK_EXPLICIT),
 -              OPT_SET_INT( 0, "set-upstream",  &track, N_("change upstream info"),
 -                      BRANCH_TRACK_OVERRIDE),
 +              { OPTION_SET_INT, 0, "set-upstream", &track, NULL, N_("do not use"),
 +                      PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, BRANCH_TRACK_OVERRIDE },
                OPT_STRING('u', "set-upstream-to", &new_upstream, N_("upstream"), N_("change the upstream info")),
                OPT_BOOL(0, "unset-upstream", &unset_upstream, N_("Unset the upstream info")),
                OPT__COLOR(&branch_use_color, N_("use colored output")),
                OPT_BIT('D', NULL, &delete, N_("delete branch (even if not merged)"), 2),
                OPT_BIT('m', "move", &rename, N_("move/rename a branch and its reflog"), 1),
                OPT_BIT('M', NULL, &rename, N_("move/rename a branch, even if target exists"), 2),
 +              OPT_BIT('c', "copy", &copy, N_("copy a branch and its reflog"), 1),
 +              OPT_BIT('C', NULL, &copy, N_("copy a branch, even if target exists"), 2),
                OPT_BOOL(0, "list", &list, N_("list branch names")),
                OPT_BOOL('l', "create-reflog", &reflog, N_("create the branch's reflog")),
                OPT_BOOL(0, "edit-description", &edit_description,
                        N_("print only branches of the object"), 0, parse_opt_object_name
                },
                OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
 -              OPT_STRING(  0 , "format", &format, N_("format"), N_("format to use for the output")),
 +              OPT_STRING(  0 , "format", &format.format, N_("format"), N_("format to use for the output")),
                OPT_END(),
        };
  
  
        track = git_branch_track;
  
 -      head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
 +      head = resolve_refdup("HEAD", 0, &head_oid, NULL);
        if (!head)
                die(_("Failed to resolve HEAD as a valid ref."));
        if (!strcmp(head, "HEAD"))
        argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
                             0);
  
 -      if (!delete && !rename && !edit_description && !new_upstream && !unset_upstream && argc == 0)
 +      if (!delete && !rename && !copy && !edit_description && !new_upstream && !unset_upstream && argc == 0)
                list = 1;
  
        if (filter.with_commit || filter.merge != REF_FILTER_MERGED_NONE || filter.points_at.nr ||
            filter.no_commit)
                list = 1;
  
 -      if (!!delete + !!rename + !!new_upstream +
 +      if (!!delete + !!rename + !!copy + !!new_upstream +
            list + unset_upstream > 1)
                usage_with_options(builtin_branch_usage, options);
  
        if (force) {
                delete *= 2;
                rename *= 2;
 +              copy *= 2;
        }
  
+       if (list)
+               setup_auto_pager("branch", 1);
        if (delete) {
                if (!argc)
                        die(_("branch name required"));
                if (!sorting)
                        sorting = ref_default_sorting();
                sorting->ignore_case = icase;
 -              print_ref_list(&filter, sorting, format);
 +              print_ref_list(&filter, sorting, &format);
                print_columns(&output, colopts, NULL);
                string_list_clear(&output, 0);
                return 0;
  
                if (edit_branch_description(branch_name))
                        return 1;
 +      } else if (copy) {
 +              if (!argc)
 +                      die(_("branch name required"));
 +              else if (argc == 1)
 +                      copy_or_rename_branch(head, argv[0], 1, copy > 1);
 +              else if (argc == 2)
 +                      copy_or_rename_branch(argv[0], argv[1], 1, copy > 1);
 +              else
 +                      die(_("too many branches for a copy operation"));
        } else if (rename) {
                if (!argc)
                        die(_("branch name required"));
                else if (argc == 1)
 -                      rename_branch(head, argv[0], rename > 1);
 +                      copy_or_rename_branch(head, argv[0], 0, rename > 1);
                else if (argc == 2)
 -                      rename_branch(argv[0], argv[1], rename > 1);
 +                      copy_or_rename_branch(argv[0], argv[1], 0, rename > 1);
                else
 -                      die(_("too many branches for a rename operation"));
 +                      die(_("too many arguments for a rename operation"));
        } else if (new_upstream) {
                struct branch *branch = branch_get(argv[0]);
  
                if (argc > 1)
 -                      die(_("too many branches to set new upstream"));
 +                      die(_("too many arguments to set new upstream"));
  
                if (!branch) {
                        if (!argc || !strcmp(argv[0], "HEAD"))
                struct strbuf buf = STRBUF_INIT;
  
                if (argc > 1)
 -                      die(_("too many branches to unset upstream"));
 +                      die(_("too many arguments to unset upstream"));
  
                if (!branch) {
                        if (!argc || !strcmp(argv[0], "HEAD"))
                strbuf_release(&buf);
        } else if (argc > 0 && argc <= 2) {
                struct branch *branch = branch_get(argv[0]);
 -              int branch_existed = 0, remote_tracking = 0;
 -              struct strbuf buf = STRBUF_INIT;
 -
 -              if (!strcmp(argv[0], "HEAD"))
 -                      die(_("it does not make sense to create 'HEAD' manually"));
  
                if (!branch)
                        die(_("no such branch '%s'"), argv[0]);
                        die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
  
                if (track == BRANCH_TRACK_OVERRIDE)
 -                      fprintf(stderr, _("The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\n"));
 -
 -              strbuf_addf(&buf, "refs/remotes/%s", branch->name);
 -              remote_tracking = ref_exists(buf.buf);
 -              strbuf_release(&buf);
 +                      die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead."));
  
 -              branch_existed = ref_exists(branch->refname);
                create_branch(argv[0], (argc == 2) ? argv[1] : head,
                              force, reflog, 0, quiet, track);
  
 -              /*
 -               * We only show the instructions if the user gave us
 -               * one branch which doesn't exist locally, but is the
 -               * name of a remote-tracking branch.
 -               */
 -              if (argc == 1 && track == BRANCH_TRACK_OVERRIDE &&
 -                  !branch_existed && remote_tracking) {
 -                      fprintf(stderr, _("\nIf you wanted to make '%s' track '%s', do this:\n\n"), head, branch->name);
 -                      fprintf(stderr, "    git branch -d %s\n", branch->name);
 -                      fprintf(stderr, "    git branch --set-upstream-to %s\n", branch->name);
 -              }
 -
        } else
                usage_with_options(builtin_branch_usage, options);
  
diff --combined git.c
index 9e96dd409017c643e8a9bebbc41281728978b0b8,df66b8b2e0546fa4675f86006a4542c84f0a032d..c870b9719c21b2db23ea7ab5d56fdeda483cb02e
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -182,10 -182,6 +182,10 @@@ static int handle_options(const char **
                        setenv(GIT_ICASE_PATHSPECS_ENVIRONMENT, "1", 1);
                        if (envchanged)
                                *envchanged = 1;
 +              } else if (!strcmp(cmd, "--no-optional-locks")) {
 +                      setenv(GIT_OPTIONAL_LOCKS_ENVIRONMENT, "0", 1);
 +                      if (envchanged)
 +                              *envchanged = 1;
                } else if (!strcmp(cmd, "--shallow-file")) {
                        (*argv)++;
                        (*argc)--;
@@@ -372,7 -368,7 +372,7 @@@ static struct cmd_struct commands[] = 
        { "archive", cmd_archive, RUN_SETUP_GENTLY },
        { "bisect--helper", cmd_bisect__helper, RUN_SETUP },
        { "blame", cmd_blame, RUN_SETUP },
-       { "branch", cmd_branch, RUN_SETUP },
+       { "branch", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG },
        { "bundle", cmd_bundle, RUN_SETUP_GENTLY },
        { "cat-file", cmd_cat_file, RUN_SETUP },
        { "check-attr", cmd_check_attr, RUN_SETUP },
        { "fsck-objects", cmd_fsck, RUN_SETUP },
        { "gc", cmd_gc, RUN_SETUP },
        { "get-tar-commit-id", cmd_get_tar_commit_id },
 -      { "grep", cmd_grep, RUN_SETUP_GENTLY | SUPPORT_SUPER_PREFIX },
 +      { "grep", cmd_grep, RUN_SETUP_GENTLY },
        { "hash-object", cmd_hash_object },
        { "help", cmd_help },
        { "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
diff --combined t/t7006-pager.sh
index 865168ec6a7be7fc7778419f2dd1066e9c80c1bc,f59dfd143209ef6b5fec7e5e8b92e9682f407392..f5f46a95b4be9bca4ca30e70cbe75051a191c96a
@@@ -214,6 -214,44 +214,44 @@@ test_expect_success TTY 'git tag as ali
        ! test -e paginated.out
  '
  
+ test_expect_success TTY 'git branch defaults to paging' '
+       rm -f paginated.out &&
+       test_terminal git branch &&
+       test -e paginated.out
+ '
+ test_expect_success TTY 'git branch respects pager.branch' '
+       rm -f paginated.out &&
+       test_terminal git -c pager.branch=false branch &&
+       ! test -e paginated.out
+ '
+ test_expect_success TTY 'git branch respects --no-pager' '
+       rm -f paginated.out &&
+       test_terminal git --no-pager branch &&
+       ! test -e paginated.out
+ '
+ test_expect_success TTY 'git branch --edit-description ignores pager.branch' '
+       rm -f paginated.out editor.used &&
+       write_script editor <<-\EOF &&
+               echo "New description" >"$1"
+               touch editor.used
+       EOF
+       EDITOR=./editor test_terminal git -c pager.branch branch --edit-description &&
+       ! test -e paginated.out &&
+       test -e editor.used
+ '
+ test_expect_success TTY 'git branch --set-upstream-to ignores pager.branch' '
+       rm -f paginated.out &&
+       git branch other &&
+       test_when_finished "git branch -D other" &&
+       test_terminal git -c pager.branch branch --set-upstream-to=other &&
+       test_when_finished "git branch --unset-upstream" &&
+       ! test -e paginated.out
+ '
  # A colored commit log will begin with an appropriate ANSI escape
  # for the first color; the text "commit" comes later.
  colorful() {
@@@ -239,7 -277,7 +277,7 @@@ test_expect_success 'no color when stdo
  test_expect_success TTY 'color when writing to a pager' '
        rm -f paginated.out &&
        test_config color.ui auto &&
 -      test_terminal env TERM=vt100 git log &&
 +      test_terminal git log &&
        colorful paginated.out
  '
  
@@@ -247,7 -285,7 +285,7 @@@ test_expect_success TTY 'colors are sup
        rm -f paginated.out &&
        test_config color.ui auto &&
        test_config color.pager false &&
 -      test_terminal env TERM=vt100 git log &&
 +      test_terminal git log &&
        ! colorful paginated.out
  '
  
@@@ -266,7 -304,7 +304,7 @@@ test_expect_success 'color when writin
  test_expect_success TTY 'colors are sent to pager for external commands' '
        test_config alias.externallog "!git log" &&
        test_config color.ui auto &&
 -      test_terminal env TERM=vt100 git -p externallog &&
 +      test_terminal git -p externallog &&
        colorful paginated.out
  '
  
@@@ -570,18 -608,4 +608,18 @@@ test_expect_success 'command with under
        test_cmp expect actual
  '
  
 +test_expect_success TTY 'git tag with auto-columns ' '
 +      test_commit one &&
 +      test_commit two &&
 +      test_commit three &&
 +      test_commit four &&
 +      test_commit five &&
 +      cat >expect <<-\EOF &&
 +      initial  one      two      three    four     five
 +      EOF
 +      test_terminal env PAGER="cat >actual" COLUMNS=80 \
 +              git -c column.ui=auto tag --sort=authordate &&
 +      test_cmp expect actual
 +'
 +
  test_done