branch: respect `pager.branch` in list-mode only
authorMartin Ågren <martin.agren@gmail.com>
Sun, 19 Nov 2017 15:03:49 +0000 (16:03 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Nov 2017 00:50:25 +0000 (09:50 +0900)
Similar to de121ffe5 (tag: respect `pager.tag` in list-mode only,
2017-08-02), use the DELAY_PAGER_CONFIG-mechanism to only respect
`pager.branch` when we are listing branches.

We have two possibilities of generalizing what that earlier commit made
to `git tag`. One is to interpret, e.g., --set-upstream-to as "it does
not use an editor, so we should page". Another, the one taken by this
commit, is to say "it does not list, so let's not page". That is in line
with the approach of the series on `pager.tag` and in particular the
wording in Documentation/git-tag.txt, which this commit reuses for
git-branch.txt.

This fixes the failing test added in the previous commit. Also adapt the
test for whether `git branch --set-upstream-to` respects `pager.branch`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-branch.txt
builtin/branch.c
git.c
t/t7006-pager.sh
index 81bd0a7b7741f175cf7a99e2aa9cbcacf42da78e..9dae1ea29568cf25da477e2d0832931794b18c81 100644 (file)
@@ -271,6 +271,12 @@ start-point is either a local or remote-tracking branch.
        pointed at by a ref being shown.  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.
+See linkgit:git-config[1].
+
 Examples
 --------
 
index 8a0595e11587aeac0f784400c43609404da3e045..3eb31cd1edf39591646e39b1963805da57c54377 100644 (file)
@@ -648,6 +648,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                rename *= 2;
        }
 
+       if (list)
+               setup_auto_pager("branch", 0);
+
        if (delete) {
                if (!argc)
                        die(_("branch name required"));
diff --git a/git.c b/git.c
index 6b6d9f68e1ea010cb951501cab1fdfa82037b878..df66b8b2e0546fa4675f86006a4542c84f0a032d 100644 (file)
--- a/git.c
+++ b/git.c
@@ -368,7 +368,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 },
index 12c72ef9672d1d14bbd4bce92175e32ced82781f..5998f7135b563a91de051d6d7839148c05f2b9d0 100755 (executable)
@@ -232,7 +232,7 @@ test_expect_success TTY 'git branch respects --no-pager' '
        ! test -e paginated.out
 '
 
-test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '
+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"
@@ -243,13 +243,13 @@ test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '
        test -e editor.used
 '
 
-test_expect_success TTY 'git branch --set-upstream-to respects pager.branch' '
+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
+       test -e paginated.out
 '
 
 # A colored commit log will begin with an appropriate ANSI escape