git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Martin Ågren" <martin.agren@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 2/3] branch: respect `pager.branch` in list-mode only
Date: Sun, 19 Nov 2017 16:03:49 +0100	[thread overview]
Message-ID: <f01753ca88cc14549c8f447105dda120ea9d38f4.1511103275.git.martin.agren@gmail.com> (raw)
In-Reply-To: <5f6be626171060e008005062560c76319b31958f.1511103275.git.martin.agren@gmail.com>

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>
---
 Documentation/git-branch.txt | 6 ++++++
 t/t7006-pager.sh             | 6 +++---
 builtin/branch.c             | 3 +++
 git.c                        | 2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index d6587c5e96..df24506e18 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -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.
+See linkgit:git-config[1].
+
 Examples
 --------
 
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 95547bb8c6..bb4fee3901 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -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
diff --git a/builtin/branch.c b/builtin/branch.c
index 33fd5fcfd1..9c74689fb0 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -675,6 +675,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		copy *= 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 9e96dd4090..c870b9719c 100644
--- a/git.c
+++ b/git.c
@@ -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 },
-- 
2.15.0.415.gac1375d7e


  reply	other threads:[~2017-11-19 15:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-19 15:03 [PATCH 1/3] t7006: add tests for how git branch paginates Martin Ågren
2017-11-19 15:03 ` Martin Ågren [this message]
2017-11-19 15:03 ` [PATCH 3/3] branch: change default of `pager.branch` to "on" Martin Ågren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f01753ca88cc14549c8f447105dda120ea9d38f4.1511103275.git.martin.agren@gmail.com \
    --to=martin.agren@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).