Skip to content

Commit b3ee740

Browse files
Martin Ågrengitster
authored andcommitted
t7006: add tests for how git tag paginates
Using, e.g., `git -c pager.tag tag -a new-tag` results in errors such as "Vim: Warning: Output is not to a terminal" and a garbled terminal. Someone who makes use of both `git tag -a` and `git tag -l` will probably not set `pager.tag`, so that `git tag -a` will actually work, at the cost of not paging output of `git tag -l`. Since we're about to change how `git tag` respects `pager.tag`, add tests around this, including how the configuration is ignored if --no-pager or --paginate are used. Construct tests with a few different subcommands. First, use -l. Second, use "no arguments" and --contains, since those imply -l. (There are more arguments which imply -l, but using these two should be enough.) Third, use -a as a representative for "not -l". Actually, the tests use `git tag -am` so no editor is launched, but that is irrelevant, since we just want to see whether the pager is used or not. Make one of the tests demonstrate the broken behavior mentioned above, where `git tag -a` respects `pager.tag`. Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 033fe3d commit b3ee740

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

t/t7006-pager.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,73 @@ test_expect_success TTY 'configuration can enable pager (from subdir)' '
134134
}
135135
'
136136

137+
test_expect_success TTY 'git tag -l defaults to not paging' '
138+
rm -f paginated.out &&
139+
test_terminal git tag -l &&
140+
! test -e paginated.out
141+
'
142+
143+
test_expect_success TTY 'git tag -l respects pager.tag' '
144+
rm -f paginated.out &&
145+
test_terminal git -c pager.tag tag -l &&
146+
test -e paginated.out
147+
'
148+
149+
test_expect_success TTY 'git tag -l respects --no-pager' '
150+
rm -f paginated.out &&
151+
test_terminal git -c pager.tag --no-pager tag -l &&
152+
! test -e paginated.out
153+
'
154+
155+
test_expect_success TTY 'git tag with no args defaults to not paging' '
156+
# no args implies -l so this should page like -l
157+
rm -f paginated.out &&
158+
test_terminal git tag &&
159+
! test -e paginated.out
160+
'
161+
162+
test_expect_success TTY 'git tag with no args respects pager.tag' '
163+
# no args implies -l so this should page like -l
164+
rm -f paginated.out &&
165+
test_terminal git -c pager.tag tag &&
166+
test -e paginated.out
167+
'
168+
169+
test_expect_success TTY 'git tag --contains defaults to not paging' '
170+
# --contains implies -l so this should page like -l
171+
rm -f paginated.out &&
172+
test_terminal git tag --contains &&
173+
! test -e paginated.out
174+
'
175+
176+
test_expect_success TTY 'git tag --contains respects pager.tag' '
177+
# --contains implies -l so this should page like -l
178+
rm -f paginated.out &&
179+
test_terminal git -c pager.tag tag --contains &&
180+
test -e paginated.out
181+
'
182+
183+
test_expect_success TTY 'git tag -a defaults to not paging' '
184+
test_when_finished "git tag -d newtag" &&
185+
rm -f paginated.out &&
186+
test_terminal git tag -am message newtag &&
187+
! test -e paginated.out
188+
'
189+
190+
test_expect_failure TTY 'git tag -a ignores pager.tag' '
191+
test_when_finished "git tag -d newtag" &&
192+
rm -f paginated.out &&
193+
test_terminal git -c pager.tag tag -am message newtag &&
194+
! test -e paginated.out
195+
'
196+
197+
test_expect_success TTY 'git tag -a respects --paginate' '
198+
test_when_finished "git tag -d newtag" &&
199+
rm -f paginated.out &&
200+
test_terminal git --paginate tag -am message newtag &&
201+
test -e paginated.out
202+
'
203+
137204
# A colored commit log will begin with an appropriate ANSI escape
138205
# for the first color; the text "commit" comes later.
139206
colorful() {

0 commit comments

Comments
 (0)