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

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

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Feb 11, 2018, 16:40 UTC
Message-ID
<450ff45707b58d6796d55cd594b50686e5d62fc2.1518365675.git.martin.agren@gmail.com>

The next couple of commits will change how `git config` handles `pager.config`, 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`. Similar work has also been done to `git branch`.

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` and `--get`, one for `--edit`, and one for simple config-setting.

In particular, use `test_expect_failure` to document that we currently respect the pager-configuration with `--edit`. 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).

Remove the test added in commit 3ba7e6e29a (config: run setup_git_directory_gently() sooner, 2010-08-05) since it has some overlap with these. We could leave it or tweak it, or place new tests like these next to it, but let's instead make the tests for `git config` similar to the ones for `git tag` and `git branch`, and place them after those.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 t/t7006-pager.sh | 42 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 7 deletions(-)
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index f5f46a95b4..5a7b757c94 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -110,13 +110,6 @@ test_expect_success TTY 'configuration can disable pager' '
 	! test -e paginated.out
 '
 
-test_expect_success TTY 'git config uses a pager if configured to' '
-	rm -f paginated.out &&
-	test_config pager.config true &&
-	test_terminal git config --list &&
-	test -e paginated.out
-'
-
 test_expect_success TTY 'configuration can enable pager (from subdir)' '
 	rm -f paginated.out &&
 	mkdir -p subdir &&
@@ -252,6 +245,41 @@ test_expect_success TTY 'git branch --set-upstream-to ignores pager.branch' '
 	! test -e paginated.out
 '
 
+test_expect_success TTY 'git config respects pager.config when setting' '
+	rm -f paginated.out &&
+	test_terminal git -c pager.config config foo.bar bar &&
+	test -e paginated.out
+'
+
+test_expect_failure TTY 'git config --edit ignores pager.config' '
+	rm -f paginated.out editor.used &&
+	write_script editor <<-\EOF &&
+		touch editor.used
+	EOF
+	EDITOR=./editor test_terminal git -c pager.config config --edit &&
+	! test -e paginated.out &&
+	test -e editor.used
+'
+
+test_expect_success TTY 'git config --get defaults to not paging' '
+	rm -f paginated.out &&
+	test_terminal git config --get foo.bar &&
+	! test -e paginated.out
+'
+
+test_expect_success TTY 'git config --get respects pager.config' '
+	rm -f paginated.out &&
+	test_terminal git -c pager.config config --get foo.bar &&
+	test -e paginated.out
+'
+
+test_expect_success TTY 'git config --list defaults to not paging' '
+	rm -f paginated.out &&
+	test_terminal git config --list &&
+	! 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.16.1.72.g5be1f00a9a
Next: Martin Ågren
Message 1 of 12 in “t7006: add tests for how git config paginates”
  1. 1/3 t7006: add tests for how git config paginatesMartin Ågren, Feb 11, 2018
  2. 2/3 config: respect `pager.config` in list/get-mode onlyMartin Ågren, Feb 11, 2018
  3. Duy NguyenFeb 13, 2018
  4. Martin ÅgrenFeb 13, 2018
  5. 3/3 config: change default of `pager.config` to "on"Martin Ågren, Feb 11, 2018
  6. Junio C HamanoFeb 12, 2018
  7. Martin ÅgrenFeb 12, 2018
  8. 0/3 Re: t7006: add tests for how git config paginatesMartin Ågren, Feb 21, 2018
  9. 1/3 t7006: add tests for how git config paginatesMartin Ågren, Feb 21, 2018
  10. 2/3 config: respect `pager.config` in list/get-mode onlyMartin Ågren, Feb 21, 2018
  11. 3/3 config: change default of `pager.config` to "on"Martin Ågren, Feb 21, 2018
  12. Junio C HamanoFeb 21, 2018

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.