1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-21 13:56:11 +02:00

Merge branch 'ma/branch-list-paginate'

"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
This commit is contained in:
Junio C Hamano 2017-11-28 13:41:49 +09:00
commit 3b49e1b0e9
4 changed files with 48 additions and 1 deletions

View File

@ -281,6 +281,12 @@ start-point is either a local or remote-tracking branch.
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
--------

View File

@ -675,6 +675,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
copy *= 2;
}
if (list)
setup_auto_pager("branch", 1);
if (delete) {
if (!argc)
die(_("branch name required"));

2
git.c
View File

@ -372,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 },

View File

@ -214,6 +214,44 @@ test_expect_success TTY 'git tag as alias respects pager.tag with -l' '
! 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() {