{"thread":{"id":"47240","subject":"[PATCH 1/3] t7006: add tests for how git branch paginates","startedAt":"2017-11-19T15:04:10Z","lastAt":"2017-11-19T15:04:21Z","messageCount":3,"participants":["Martin Ågren"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"332851","messageId":"5f6be626171060e008005062560c76319b31958f.1511103275.git.martin.agren@gmail.com","threadId":"47240","inReplyTo":null,"subject":"[PATCH 1/3] t7006: add tests for how git branch paginates","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2017-11-19T15:03:48Z","receivedAt":"2017-11-19T15:04:10Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"The next couple of commits will change how `git branch` handles\n`pager.branch`, similar to how de121ffe5 (tag: respect `pager.tag` in\nlist-mode only, 2017-08-02) and ff1e72483 (tag: change default of\n`pager.tag` to \"on\", 2017-08-02) changed `git tag`.\n\nAdd tests in this area to make sure that we don't regress and so that\nthe upcoming commits can be made clearer by adapting the tests. Add some\ntests for `--list` (implied), one for `--edit-description`, and one for\n`--set-upstream-to` as a representative of \"something other than the\nfirst two\".\n\nIn particular, use `test_expect_failure` to document that we currently\nrespect the pager-configuration with `--edit-description`. The current\nbehavior is buggy since the pager interferes with the editor and makes\nthe end result completely broken. See also b3ee740c8 (t7006: add tests\nfor how git tag paginates, 2017-08-02).\n\nSigned-off-by: Martin Ågren <martin.agren@gmail.com>\n---\n t/t7006-pager.sh | 38 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 38 insertions(+)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 865168ec6a..95547bb8c6 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -214,6 +214,44 @@ test_expect_success TTY 'git tag as alias respects pager.tag with -l' '\n \t! test -e paginated.out\n '\n \n+test_expect_success TTY 'git branch defaults to not paging' '\n+\trm -f paginated.out &&\n+\ttest_terminal git branch &&\n+\t! test -e paginated.out\n+'\n+\n+test_expect_success TTY 'git branch respects pager.branch' '\n+\trm -f paginated.out &&\n+\ttest_terminal git -c pager.branch branch &&\n+\ttest -e paginated.out\n+'\n+\n+test_expect_success TTY 'git branch respects --no-pager' '\n+\trm -f paginated.out &&\n+\ttest_terminal git -c pager.branch --no-pager branch &&\n+\t! test -e paginated.out\n+'\n+\n+test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '\n+\trm -f paginated.out editor.used &&\n+\twrite_script editor <<-\\EOF &&\n+\t\techo \"New description\" >\"$1\"\n+\t\ttouch editor.used\n+\tEOF\n+\tEDITOR=./editor test_terminal git -c pager.branch branch --edit-description &&\n+\t! test -e paginated.out &&\n+\ttest -e editor.used\n+'\n+\n+test_expect_success TTY 'git branch --set-upstream-to respects pager.branch' '\n+\trm -f paginated.out &&\n+\tgit branch other &&\n+\ttest_when_finished \"git branch -D other\" &&\n+\ttest_terminal git -c pager.branch branch --set-upstream-to=other &&\n+\ttest_when_finished \"git branch --unset-upstream\" &&\n+\ttest -e paginated.out\n+'\n+\n # A colored commit log will begin with an appropriate ANSI escape\n # for the first color; the text \"commit\" comes later.\n colorful() {\n-- \n2.15.0.415.gac1375d7e\n\n"},{"id":"332852","messageId":"f01753ca88cc14549c8f447105dda120ea9d38f4.1511103275.git.martin.agren@gmail.com","threadId":"47240","inReplyTo":"5f6be626171060e008005062560c76319b31958f.1511103275.git.martin.agren@gmail.com","subject":"[PATCH 2/3] branch: respect `pager.branch` in list-mode only","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2017-11-19T15:03:49Z","receivedAt":"2017-11-19T15:04:16Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"Similar to de121ffe5 (tag: respect `pager.tag` in list-mode only,\n2017-08-02), use the DELAY_PAGER_CONFIG-mechanism to only respect\n`pager.branch` when we are listing branches.\n\nWe have two possibilities of generalizing what that earlier commit made\nto `git tag`. One is to interpret, e.g., --set-upstream-to as \"it does\nnot use an editor, so we should page\". Another, the one taken by this\ncommit, is to say \"it does not list, so let's not page\". That is in line\nwith the approach of the series on `pager.tag` and in particular the\nwording in Documentation/git-tag.txt, which this commit reuses for\ngit-branch.txt.\n\nThis fixes the failing test added in the previous commit. Also adapt the\ntest for whether `git branch --set-upstream-to` respects `pager.branch`.\n\nSigned-off-by: Martin Ågren <martin.agren@gmail.com>\n---\n Documentation/git-branch.txt | 6 ++++++\n t/t7006-pager.sh             | 6 +++---\n builtin/branch.c             | 3 +++\n git.c                        | 2 +-\n 4 files changed, 13 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex d6587c5e96..df24506e18 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -281,6 +281,12 @@ start-point is either a local or remote-tracking branch.\n \tand the object it points at.  The format is the same as\n \tthat of linkgit:git-for-each-ref[1].\n \n+CONFIGURATION\n+-------------\n+`pager.branch` is only respected when listing branches, i.e., when\n+`--list` is used or implied.\n+See linkgit:git-config[1].\n+\n Examples\n --------\n \ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 95547bb8c6..bb4fee3901 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -232,7 +232,7 @@ test_expect_success TTY 'git branch respects --no-pager' '\n \t! test -e paginated.out\n '\n \n-test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '\n+test_expect_success TTY 'git branch --edit-description ignores pager.branch' '\n \trm -f paginated.out editor.used &&\n \twrite_script editor <<-\\EOF &&\n \t\techo \"New description\" >\"$1\"\n@@ -243,13 +243,13 @@ test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '\n \ttest -e editor.used\n '\n \n-test_expect_success TTY 'git branch --set-upstream-to respects pager.branch' '\n+test_expect_success TTY 'git branch --set-upstream-to ignores pager.branch' '\n \trm -f paginated.out &&\n \tgit branch other &&\n \ttest_when_finished \"git branch -D other\" &&\n \ttest_terminal git -c pager.branch branch --set-upstream-to=other &&\n \ttest_when_finished \"git branch --unset-upstream\" &&\n-\ttest -e paginated.out\n+\t! test -e paginated.out\n '\n \n # A colored commit log will begin with an appropriate ANSI escape\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 33fd5fcfd1..9c74689fb0 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -675,6 +675,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tcopy *= 2;\n \t}\n \n+\tif (list)\n+\t\tsetup_auto_pager(\"branch\", 0);\n+\n \tif (delete) {\n \t\tif (!argc)\n \t\t\tdie(_(\"branch name required\"));\ndiff --git a/git.c b/git.c\nindex 9e96dd4090..c870b9719c 100644\n--- a/git.c\n+++ b/git.c\n@@ -372,7 +372,7 @@ static struct cmd_struct commands[] = {\n \t{ \"archive\", cmd_archive, RUN_SETUP_GENTLY },\n \t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP },\n \t{ \"blame\", cmd_blame, RUN_SETUP },\n-\t{ \"branch\", cmd_branch, RUN_SETUP },\n+\t{ \"branch\", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG },\n \t{ \"bundle\", cmd_bundle, RUN_SETUP_GENTLY },\n \t{ \"cat-file\", cmd_cat_file, RUN_SETUP },\n \t{ \"check-attr\", cmd_check_attr, RUN_SETUP },\n-- \n2.15.0.415.gac1375d7e\n\n"},{"id":"332853","messageId":"ef9b1f9e3cd70bdf3500a242781f9ba030bbf8aa.1511103275.git.martin.agren@gmail.com","threadId":"47240","inReplyTo":"5f6be626171060e008005062560c76319b31958f.1511103275.git.martin.agren@gmail.com","subject":"[PATCH 3/3] branch: change default of `pager.branch` to \"on\"","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2017-11-19T15:03:50Z","receivedAt":"2017-11-19T15:04:21Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"This is similar to ff1e72483 (tag: change default of `pager.tag` to\n\"on\", 2017-08-02) and is safe now that we do not consider `pager.branch`\nat all when we are not listing branches. This change will help with\nlisting many branches, but will not hurt users of `git branch\n--edit-description` as it would have before the previous commit.\n\nSigned-off-by: Martin Ågren <martin.agren@gmail.com>\n---\n Documentation/git-branch.txt |  2 +-\n t/t7006-pager.sh             | 10 +++++-----\n builtin/branch.c             |  2 +-\n 3 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex df24506e18..520c53b5e8 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -284,7 +284,7 @@ start-point is either a local or remote-tracking branch.\n CONFIGURATION\n -------------\n `pager.branch` is only respected when listing branches, i.e., when\n-`--list` is used or implied.\n+`--list` is used or implied. The default is to use a pager.\n See linkgit:git-config[1].\n \n Examples\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex bb4fee3901..f5f46a95b4 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -214,21 +214,21 @@ test_expect_success TTY 'git tag as alias respects pager.tag with -l' '\n \t! test -e paginated.out\n '\n \n-test_expect_success TTY 'git branch defaults to not paging' '\n+test_expect_success TTY 'git branch defaults to paging' '\n \trm -f paginated.out &&\n \ttest_terminal git branch &&\n-\t! test -e paginated.out\n+\ttest -e paginated.out\n '\n \n test_expect_success TTY 'git branch respects pager.branch' '\n \trm -f paginated.out &&\n-\ttest_terminal git -c pager.branch branch &&\n-\ttest -e paginated.out\n+\ttest_terminal git -c pager.branch=false branch &&\n+\t! test -e paginated.out\n '\n \n test_expect_success TTY 'git branch respects --no-pager' '\n \trm -f paginated.out &&\n-\ttest_terminal git -c pager.branch --no-pager branch &&\n+\ttest_terminal git --no-pager branch &&\n \t! test -e paginated.out\n '\n \ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 9c74689fb0..4e6b8c3bc1 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -676,7 +676,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (list)\n-\t\tsetup_auto_pager(\"branch\", 0);\n+\t\tsetup_auto_pager(\"branch\", 1);\n \n \tif (delete) {\n \t\tif (!argc)\n-- \n2.15.0.415.gac1375d7e\n\n"}]}