git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] t7006: add tests for how git branch paginates

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Nov 19, 2017, 15:03 UTC
Message-ID
<5f6be626171060e008005062560c76319b31958f.1511103275.git.martin.agren@gmail.com>

The next couple of commits will change how `git branch` handles `pager.branch`, similar to how de121ffe5 (tag: respect `pager.tag` in list-mode only, 2017-08-02) and ff1e72483 (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 b3ee740c8 (t7006: add tests for how git tag paginates, 2017-08-02).

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 t/t7006-pager.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 865168ec6a..95547bb8c6 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -214,6 +214,44 @@ test_expect_success TTY 'git tag as alias respects pager.tag with -l' '
 	! test -e paginated.out
 '
 
+test_expect_success TTY 'git branch defaults to not paging' '
+	rm -f paginated.out &&
+	test_terminal git branch &&
+	! test -e paginated.out
+'
+
+test_expect_success TTY 'git branch respects pager.branch' '
+	rm -f paginated.out &&
+	test_terminal git -c pager.branch branch &&
+	test -e paginated.out
+'
+
+test_expect_success TTY 'git branch respects --no-pager' '
+	rm -f paginated.out &&
+	test_terminal git -c pager.branch --no-pager branch &&
+	! test -e paginated.out
+'
+
+test_expect_failure TTY 'git branch --edit-description ignores pager.branch' '
+	rm -f paginated.out editor.used &&
+	write_script editor <<-\EOF &&
+		echo "New description" >"$1"
+		touch editor.used
+	EOF
+	EDITOR=./editor test_terminal git -c pager.branch branch --edit-description &&
+	! test -e paginated.out &&
+	test -e editor.used
+'
+
+test_expect_success TTY 'git branch --set-upstream-to respects 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
+'
+
 # A colored commit log will begin with an appropriate ANSI escape
 # for the first color; the text "commit" comes later.
 colorful() {
-- 
2.15.0.415.gac1375d7e
Next: Martin Ågren
Message 1 of 3 in “t7006: add tests for how git branch paginates”
  1. 1/3 t7006: add tests for how git branch paginatesMartin Ågren, Nov 19, 2017
  2. 2/3 branch: respect `pager.branch` in list-mode onlyMartin Ågren, Nov 19, 2017
  3. 3/3 branch: change default of `pager.branch` to "on"Martin Ågren, Nov 19, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.