summaryrefslogtreecommitdiff
path: root/t/t7006-pager.sh
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2018-02-21 18:51:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-02-21 22:27:27 (GMT)
commitcd878a206e8ca67b215de5fa510f0ef30bb6e1c6 (patch)
treef9f58b3497862118f1aaf4cb156b295057bb9716 /t/t7006-pager.sh
parent5be1f00a9a701532232f57958efab4be8c959a29 (diff)
downloadgit-cd878a206e8ca67b215de5fa510f0ef30bb6e1c6.zip
git-cd878a206e8ca67b215de5fa510f0ef30bb6e1c6.tar.gz
git-cd878a206e8ca67b215de5fa510f0ef30bb6e1c6.tar.bz2
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>
Diffstat (limited to 't/t7006-pager.sh')
-rwxr-xr-xt/t7006-pager.sh49
1 files changed, 42 insertions, 7 deletions
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index f5f46a9..a46a079 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,48 @@ 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 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 --get-urlmatch defaults to not paging' '
+ rm -f paginated.out &&
+ test_terminal git -c http."https://foo.com/".bar=foo \
+ config --get-urlmatch http https://foo.com &&
+ ! test -e paginated.out
+'
+
+test_expect_success TTY 'git config --get-all respects pager.config' '
+ rm -f paginated.out &&
+ test_terminal git -c pager.config config --get-all 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() {