Skip to content

Commit d74b541

Browse files
Martin Ågrengitster
authored andcommitted
branch: respect pager.branch in list-mode only
Similar to de121ff (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed104fa commit d74b541

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

Documentation/git-branch.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ start-point is either a local or remote-tracking branch.
271271
pointed at by a ref being shown. The format is the same as
272272
that of linkgit:git-for-each-ref[1].
273273

274+
CONFIGURATION
275+
-------------
276+
`pager.branch` is only respected when listing branches, i.e., when
277+
`--list` is used or implied.
278+
See linkgit:git-config[1].
279+
274280
Examples
275281
--------
276282

builtin/branch.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
648648
rename *= 2;
649649
}
650650

651+
if (list)
652+
setup_auto_pager("branch", 0);
653+
651654
if (delete) {
652655
if (!argc)
653656
die(_("branch name required"));

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static struct cmd_struct commands[] = {
368368
{ "archive", cmd_archive, RUN_SETUP_GENTLY },
369369
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP },
370370
{ "blame", cmd_blame, RUN_SETUP },
371-
{ "branch", cmd_branch, RUN_SETUP },
371+
{ "branch", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG },
372372
{ "bundle", cmd_bundle, RUN_SETUP_GENTLY },
373373
{ "cat-file", cmd_cat_file, RUN_SETUP },
374374
{ "check-attr", cmd_check_attr, RUN_SETUP },

t/t7006-pager.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ test_expect_success TTY 'git branch respects --no-pager' '
232232
! test -e paginated.out
233233
'
234234

235-
test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '
235+
test_expect_success TTY 'git branch --edit-description ignores pager.branch' '
236236
rm -f paginated.out editor.used &&
237237
write_script editor <<-\EOF &&
238238
echo "New description" >"$1"
@@ -243,13 +243,13 @@ test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '
243243
test -e editor.used
244244
'
245245

246-
test_expect_success TTY 'git branch --set-upstream-to respects pager.branch' '
246+
test_expect_success TTY 'git branch --set-upstream-to ignores pager.branch' '
247247
rm -f paginated.out &&
248248
git branch other &&
249249
test_when_finished "git branch -D other" &&
250250
test_terminal git -c pager.branch branch --set-upstream-to=other &&
251251
test_when_finished "git branch --unset-upstream" &&
252-
test -e paginated.out
252+
! test -e paginated.out
253253
'
254254

255255
# A colored commit log will begin with an appropriate ANSI escape

0 commit comments

Comments
 (0)