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

[PATCH 4/4] pager: make `pager.foo.command` imply `.enable=true`

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Nov 5, 2017, 11:58 UTC
Message-ID
<d8e25efe07e72eeef887d7af06f23b69f9b227ec.1509879269.git.martin.agren@gmail.com>
In-Reply-To
<cover.1509879269.git.martin.agren@gmail.com>

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@gmail.com>
---
 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
Previous: Martin ÅgrenNext: Jeff King
Message 8 of 11 in “Git Open Source Weekend London 11th/12th November”
  1. Thomas GummererNov 1, 2017
  2. Jeff KingNov 4, 2017
  3. Philip OakleyNov 4, 2017
  4. 0/4 first steps towards pager.foo.{command,enable}Martin Ågren, Nov 5, 2017
  5. 1/4 t7006: document that `pager.foo` can be partially preservedMartin Ågren, Nov 5, 2017
  6. 2/4 pager: refactor `pager_command_config()`Martin Ågren, Nov 5, 2017
  7. 3/4 pager: introduce `pager.*.command` and `.enable`Martin Ågren, Nov 5, 2017
  8. 4/4 pager: make `pager.foo.command` imply `.enable=true`Martin Ågren, Nov 5, 2017
  9. Jeff KingNov 6, 2017
  10. Martin ÅgrenNov 7, 2017
  11. Patrick SteinhardtNov 5, 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.