Skip to content

Commit ed104fa

Browse files
Martin Ågrengitster
authored andcommitted
t7006: add tests for how git branch paginates
The next couple of commits will change how `git branch` handles `pager.branch`, similar to how de121ff (tag: respect `pager.tag` in list-mode only, 2017-08-02) and ff1e724 (tag: change default of `pager.tag` to "on", 2017-08-02) changed `git tag`. Add tests in this area to make sure that we don't regress and so that the upcoming commits can be made clearer by adapting the tests. Add some tests for `--list` (implied), one for `--edit-description`, and one for `--set-upstream-to` as a representative of "something other than the first two". In particular, use `test_expect_failure` to document that we currently respect the pager-configuration with `--edit-description`. The current behavior is buggy since the pager interferes with the editor and makes the end result completely broken. See also b3ee740 (t7006: add tests for how git tag paginates, 2017-08-02). Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 595d59e commit ed104fa

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

t/t7006-pager.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,44 @@ test_expect_success TTY 'git tag as alias respects pager.tag with -l' '
214214
! test -e paginated.out
215215
'
216216

217+
test_expect_success TTY 'git branch defaults to not paging' '
218+
rm -f paginated.out &&
219+
test_terminal git branch &&
220+
! test -e paginated.out
221+
'
222+
223+
test_expect_success TTY 'git branch respects pager.branch' '
224+
rm -f paginated.out &&
225+
test_terminal git -c pager.branch branch &&
226+
test -e paginated.out
227+
'
228+
229+
test_expect_success TTY 'git branch respects --no-pager' '
230+
rm -f paginated.out &&
231+
test_terminal git -c pager.branch --no-pager branch &&
232+
! test -e paginated.out
233+
'
234+
235+
test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '
236+
rm -f paginated.out editor.used &&
237+
write_script editor <<-\EOF &&
238+
echo "New description" >"$1"
239+
touch editor.used
240+
EOF
241+
EDITOR=./editor test_terminal git -c pager.branch branch --edit-description &&
242+
! test -e paginated.out &&
243+
test -e editor.used
244+
'
245+
246+
test_expect_success TTY 'git branch --set-upstream-to respects pager.branch' '
247+
rm -f paginated.out &&
248+
git branch other &&
249+
test_when_finished "git branch -D other" &&
250+
test_terminal git -c pager.branch branch --set-upstream-to=other &&
251+
test_when_finished "git branch --unset-upstream" &&
252+
test -e paginated.out
253+
'
254+
217255
# A colored commit log will begin with an appropriate ANSI escape
218256
# for the first color; the text "commit" comes later.
219257
colorful() {

0 commit comments

Comments
 (0)