If `pager.foo.command` gets configured and there is no configuration (yet) saying whether we should page, act as if `pager.foo.enable=true`. This means that a lone `pager.foo` can always be written as a lone `pager.foo.command` or `pager.foo.enable`. Signed-off-by: Martin Ågren <martin.agren@xxxxxxxxx> --- Documentation/config.txt | 2 ++ t/t7006-pager.sh | 7 +++++++ pager.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index 72558cc74..91cc8b110 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -2470,6 +2470,8 @@ pager.<cmd>.command:: Specifies the pager to use for the subcommand. Whether the pager should be used is configured using `pager.<cmd>.enable` or `pager.<cmd>=<boolean>`. + Implies `pager.<cmd>.enable=true` unless `pager.<cmd>.enable` + or `pager.<cmd>` have already been given. pager.<cmd>.enable:: A boolean which turns on or off pagination of the output of a diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index 6966627dd..c5246a57d 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -625,6 +625,13 @@ test_expect_success TTY '.enable discards non-boolean' ' test_must_fail git -c pager.log.enable=bad log ' +test_expect_success TTY 'configuration with .command turns on paging' ' + >actual && + test_terminal git -c pager.rev-list.command="sed s/^/foo:/ >actual" \ + rev-list HEAD && + test_cmp expect actual +' + test_expect_success TTY 'configuration remembers .command as .enable flips' ' >actual && test_terminal git -c pager.rev-list.command="sed s/^/foo:/ >actual" \ diff --git a/pager.c b/pager.c index c8a6a01d8..0e037abf4 100644 --- a/pager.c +++ b/pager.c @@ -209,6 +209,8 @@ static int pager_command_config(const char *var, const char *value, void *vdata) } else if (!strcmp(remainder, ".command")) { free(data->value); data->value = xstrdup(value); + if (data->want == -1) + data->want = 1; } else if (!strcmp(remainder, ".enable")) { data->want = git_config_bool(var, value); } -- 2.15.0.415.gac1375d7e