t7006: add tests for how git config paginates

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 tests for simple config-setting, `--edit`, `--get`, `--get-urlmatch`, `get-all`, and `--list`. Those represent a fair portion of the various options that will be affected by the next two commits. 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). The next commit will teach simple config-setting and `--get` to ignore `pager.config`. Test the current behavior as "success", not "failure", since the currently expected behavior according to documentation would be to page. The next commit will change that expectation by updating the documentation on `git config` and will redefine those successful tests. 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` as similar as possible to the ones for `git tag` and `git branch`, and place them after those. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Ågren committed Feb 21, 2018 at 19:51 UTC cd878a206e8ca67b215de5fa510f0ef30bb6e1c6
1 file changed +42 -7
t/t7006-pager.sh
+42 -7
@@ -110,13 +110,6 @@ test_expect_success TTY 'configuration can disable pager' '
110 ! test -e paginated.out
111 '
112
113 -test_expect_success TTY 'git config uses a pager if configured to' '
114 - rm -f paginated.out &&
115 - test_config pager.config true &&
116 - test_terminal git config --list &&
117 - test -e paginated.out
118 -'
119 -
113 test_expect_success TTY 'configuration can enable pager (from subdir)' '
114 rm -f paginated.out &&
115 mkdir -p subdir &&
@@ -252,6 +245,48 @@ test_expect_success TTY 'git branch --set-upstream-to ignores pager.branch' '
245 ! test -e paginated.out
246 '
247
248 +test_expect_success TTY 'git config respects pager.config when setting' '
249 + rm -f paginated.out &&
250 + test_terminal git -c pager.config config foo.bar bar &&
251 + test -e paginated.out
252 +'
253 +
254 +test_expect_failure TTY 'git config --edit ignores pager.config' '
255 + rm -f paginated.out editor.used &&
256 + write_script editor <<-\EOF &&
257 + touch editor.used
258 + EOF
259 + EDITOR=./editor test_terminal git -c pager.config config --edit &&
260 + ! test -e paginated.out &&
261 + test -e editor.used
262 +'
263 +
264 +test_expect_success TTY 'git config --get respects pager.config' '
265 + rm -f paginated.out &&
266 + test_terminal git -c pager.config config --get foo.bar &&
267 + test -e paginated.out
268 +'
269 +
270 +test_expect_success TTY 'git config --get-urlmatch defaults to not paging' '
271 + rm -f paginated.out &&
272 + test_terminal git -c http."https://foo.com/".bar=foo \
273 + config --get-urlmatch http https://foo.com &&
274 + ! test -e paginated.out
275 +'
276 +
277 +test_expect_success TTY 'git config --get-all respects pager.config' '
278 + rm -f paginated.out &&
279 + test_terminal git -c pager.config config --get-all foo.bar &&
280 + test -e paginated.out
281 +'
282 +
283 +test_expect_success TTY 'git config --list defaults to not paging' '
284 + rm -f paginated.out &&
285 + test_terminal git config --list &&
286 + ! test -e paginated.out
287 +'
288 +
289 +
290 # A colored commit log will begin with an appropriate ANSI escape
291 # for the first color; the text "commit" comes later.
292 colorful() {