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

[PATCH] git --paginate: paginate external commands again

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 14, 2010, 22:55 UTC
Message-ID
<20100714225512.GA13636@burratino>
In-Reply-To
<7v630hyf5r.fsf@alter.siamese.dyndns.org>

73e25e7c (git --paginate: do not commit pager choice too early, 2010-06-26) failed to take some cases into account.

1b. Builtins that do not use RUN_SETUP (like git config) do
    not find GIT_DIR set correctly when the pager is launched
    from run_builtin().  So the core.pager configuration is
    not honored from subdirectories of the toplevel for them.
4a. External git commands (like git request-pull) relied on the
    early pager launch to take care of handling the -p option.
    Ever since 73e25e7c, they do not honor the -p option at all.
4b. Commands invoked through ! aliases (like ls) were also relying
    on the early pager launch.

Fix (4a) by launching the pager (if requested) before running such a “dashed external”. For simplicity, this still does not search for a .git directory before running the external command; when run from a subdirectory of the toplevel, therefore, the “[core] pager” configuration is still not honored.

Fix (4b) by launching pager if requested before carrying out such an alias. Actually doing this has no effect, since the pager (if any) would have already been launched in a failed attempt to try a dashed external first. The choice-of-pager-not-honored-from- subdirectory bug still applies here, too.

(1b) is not a regression.  There is no need to fix it yet.
Noticed by Junio.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Junio C Hamano wrote:
> I hate an enumeration that pretends to be exhausitive but is not.
Sorry about that.
Here’s a patch that could be squashed in or applied on top.
 git.c            |    3 +++
 t/t7006-pager.sh |   47 +++++++++++++++++++++++++++++++++++------------
 2 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/git.c b/git.c
index 25e7693..99517dd 100644
--- a/git.c
+++ b/git.c
@@ -167,6 +167,7 @@ static int handle_alias(int *argcp, const char ***argv)
 	alias_string = alias_lookup(alias_command);
 	if (alias_string) {
 		if (alias_string[0] == '!') {
+			commit_pager_choice();
 			if (*argcp > 1) {
 				struct strbuf buf;
 
@@ -432,6 +433,8 @@ static void execv_dashed_external(const char **argv)
 	const char *tmp;
 	int status;
 
+	commit_pager_choice();
+
 	strbuf_addf(&cmd, "git-%s", argv[0]);
 
 	/*
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index eefef45..9215c2f 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -334,17 +334,40 @@ test_doesnt_paginate() {
 	"
 }
 
-test_default_pager        expect_success 'git log'
-test_PAGER_overrides      expect_success 'git log'
-test_core_pager_overrides expect_success 'git log'
-test_core_pager_subdir    expect_success 'git log'
-test_GIT_PAGER_overrides  expect_success 'git log'
-
-test_default_pager        expect_success 'git -p log'
-test_PAGER_overrides      expect_success 'git -p log'
-test_core_pager_overrides expect_success 'git -p log'
-test_core_pager_subdir    expect_success 'git -p log'
-test_GIT_PAGER_overrides  expect_success 'git -p log'
+test_pager_choices() {
+	test_default_pager        expect_success "$@"
+	test_PAGER_overrides      expect_success "$@"
+	test_core_pager_overrides expect_success "$@"
+	test_core_pager_subdir    expect_success "$@"
+	test_GIT_PAGER_overrides  expect_success "$@"
+}
+
+test_expect_success 'setup: some aliases' '
+	git config alias.aliasedlog log &&
+	git config alias.true "!true"
+'
+
+test_pager_choices                       'git log'
+test_pager_choices                       'git -p log'
+test_pager_choices                       'git aliasedlog'
+
+test_default_pager        expect_success 'git -p aliasedlog'
+test_PAGER_overrides      expect_success 'git -p aliasedlog'
+test_core_pager_overrides expect_success 'git -p aliasedlog'
+test_core_pager_subdir    expect_failure 'git -p aliasedlog'
+test_GIT_PAGER_overrides  expect_success 'git -p aliasedlog'
+
+test_default_pager        expect_success 'git -p true'
+test_PAGER_overrides      expect_success 'git -p true'
+test_core_pager_overrides expect_success 'git -p true'
+test_core_pager_subdir    expect_failure 'git -p true'
+test_GIT_PAGER_overrides  expect_success 'git -p true'
+
+test_default_pager        expect_success test_must_fail 'git -p request-pull'
+test_PAGER_overrides      expect_success test_must_fail 'git -p request-pull'
+test_core_pager_overrides expect_success test_must_fail 'git -p request-pull'
+test_core_pager_subdir    expect_failure test_must_fail 'git -p request-pull'
+test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p request-pull'
 
 test_default_pager        expect_success test_must_fail 'git -p'
 test_PAGER_overrides      expect_success test_must_fail 'git -p'
@@ -352,6 +375,6 @@ test_local_config_ignored expect_failure test_must_fail 'git -p'
 test_no_local_config_subdir expect_success test_must_fail 'git -p'
 test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p'
 
-test_doesnt_paginate      expect_success test_must_fail 'git -p nonsense'
+test_doesnt_paginate      expect_failure test_must_fail 'git -p nonsense'
 
 test_done
-- 
1.7.2.rc2.532.g65d9b.dirty
Previous: Jonathan NiederNext: Nguyen Thai Ngoc Duy
Message 14 of 42 in “git --paginate: do not commit pager choice too early”
  1. 0/4 git --paginate: do not commit pager choice too earlyJonathan Nieder, Jun 26, 2010
  2. 1/4 t7006 (pager): introduce helper for parameterized testsJonathan Nieder, Jun 26, 2010
  3. 2/4 t7006: test pager configuration for several git commandsJonathan Nieder, Jun 26, 2010
  4. Jonathan NiederJun 26, 2010
  5. 3/4 tests: local config file should be honored from subdirs of toplevelJonathan Nieder, Jun 26, 2010
  6. 4/4 git --paginate: do not commit pager choice too earlyJonathan Nieder, Jun 26, 2010
  7. Jeff KingJun 28, 2010
  8. Jonathan NiederJun 28, 2010
  9. Jeff KingJun 28, 2010
  10. Nguyen Thai Ngoc DuyJun 28, 2010
  11. Junio C HamanoJun 29, 2010
  12. Junio C HamanoJul 14, 2010
  13. Jonathan NiederJul 14, 2010
  14. git --paginate: paginate external commands againJonathan Nieder, Jul 14, 2010
  15. Nguyen Thai Ngoc DuyJul 18, 2010
  16. 0/12 Re: git --paginate: do not commit pager choice too earlyJonathan Nieder, Aug 6, 2010
  17. 01/12 git wrapper: introduce startup_info structJonathan Nieder, Aug 6, 2010
  18. 02/12 setup: remember whether repository was foundJonathan Nieder, Aug 6, 2010
  19. 03/12 git wrapper: allow setup_git_directory_gently() be called earlierJonathan Nieder, Aug 6, 2010
  20. 04/12 shortlog: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  21. 05/12 grep: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  22. 06/12 apply: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  23. Ævar Arnfjörð BjarmasonAug 15, 2010
  24. Nguyen Thai Ngoc DuyAug 15, 2010
  25. Jonathan NiederAug 15, 2010
  26. 06/12 apply: run setup_git_directory_gently() soonerNguyễn Thái Ngọc Duy, Aug 16, 2010
  27. Junio C HamanoAug 16, 2010
  28. 07/12 bundle: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  29. Thomas RastAug 16, 2010
  30. Jonathan NiederAug 16, 2010
  31. 2/2 t7006 (pager): add missing TTY prerequisiteJonathan Nieder, Aug 16, 2010
  32. Junio C HamanoAug 16, 2010
  33. 08/12 config: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  34. 09/12 index-pack: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  35. 10/12 ls-remote: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  36. 11/12 var: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  37. 12/12 merge-file: run setup_git_directory_gently() soonerJonathan Nieder, Aug 6, 2010
  38. 0/2 fix "check-ref-format --branch" from subdir of toplevelJonathan Nieder, Aug 6, 2010
  39. 1/2 check-ref-format: handle subcommands in separate functionsJonathan Nieder, Aug 6, 2010
  40. 2/2 Allow "check-ref-format --branch" from subdirectoryJonathan Nieder, Aug 6, 2010
  41. Junio C HamanoAug 6, 2010
  42. Nguyen Thai Ngoc DuyAug 6, 2010

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.