git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Jeff King" <peff@peff.net>
Subject: [PATCH] git --paginate: paginate external commands again
Date: Wed, 14 Jul 2010 17:55:12 -0500	[thread overview]
Message-ID: <20100714225512.GA13636@burratino> (raw)
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

  parent reply	other threads:[~2010-07-14 22:56 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-26 19:22 [PATCH 0/4] git --paginate: do not commit pager choice too early Jonathan Nieder
2010-06-26 19:23 ` [PATCH 1/4] t7006 (pager): introduce helper for parameterized tests Jonathan Nieder
2010-06-26 19:24 ` [PATCH 2/4] t7006: test pager configuration for several git commands Jonathan Nieder
2010-06-26 19:28   ` Jonathan Nieder
2010-06-26 19:25 ` [PATCH 3/4] tests: local config file should be honored from subdirs of toplevel Jonathan Nieder
2010-06-26 19:26 ` [PATCH 4/4] git --paginate: do not commit pager choice too early Jonathan Nieder
2010-06-28  9:40 ` [PATCH 0/4] " Jeff King
2010-06-28 10:13   ` Jonathan Nieder
2010-06-28 10:22     ` Jeff King
2010-06-28 12:45       ` Nguyen Thai Ngoc Duy
2010-06-29  5:42 ` Junio C Hamano
2010-07-14 20:36   ` Junio C Hamano
2010-07-14 21:30     ` Jonathan Nieder
2010-07-14 22:55     ` Jonathan Nieder [this message]
2010-07-18 12:27     ` Nguyen Thai Ngoc Duy
2010-08-06  2:35     ` [PATCH jn/paginate-fix 0/12] " Jonathan Nieder
2010-08-06  2:40       ` [PATCH 01/12] git wrapper: introduce startup_info struct Jonathan Nieder
2010-08-06  2:46       ` [PATCH 02/12] setup: remember whether repository was found Jonathan Nieder
2010-08-06  2:52       ` [PATCH 03/12] git wrapper: allow setup_git_directory_gently() be called earlier Jonathan Nieder
2010-08-06  3:01       ` [PATCH 04/12] shortlog: run setup_git_directory_gently() sooner Jonathan Nieder
2010-08-06  3:06       ` [PATCH 05/12] grep: " Jonathan Nieder
2010-08-06  3:08       ` [PATCH 06/12] apply: " Jonathan Nieder
2010-08-15 20:13         ` Ævar Arnfjörð Bjarmason
2010-08-15 22:34           ` Nguyen Thai Ngoc Duy
2010-08-15 23:11             ` Jonathan Nieder
2010-08-16  0:36         ` [PATCH 06/12 v2] " Nguyễn Thái Ngọc Duy
2010-08-16  3:39           ` Junio C Hamano
2010-08-06  3:12       ` [PATCH 07/12] bundle: " Jonathan Nieder
2010-08-16  7:21         ` Thomas Rast
2010-08-16  8:07           ` Jonathan Nieder
2010-08-16  8:11             ` [PATCH 2/2] t7006 (pager): add missing TTY prerequisite Jonathan Nieder
2010-08-16 16:41               ` Junio C Hamano
2010-08-06  3:15       ` [PATCH 08/12] config: run setup_git_directory_gently() sooner Jonathan Nieder
2010-08-06  3:18       ` [PATCH 09/12] index-pack: " Jonathan Nieder
2010-08-06  3:20       ` [PATCH 10/12] ls-remote: " Jonathan Nieder
2010-08-06  3:21       ` [PATCH 11/12] var: " Jonathan Nieder
2010-08-06  3:27       ` [PATCH 12/12] merge-file: " Jonathan Nieder
2010-08-06  3:34       ` [PATCH master 0/2] fix "check-ref-format --branch" from subdir of toplevel Jonathan Nieder
2010-08-06  3:36         ` [PATCH 1/2] check-ref-format: handle subcommands in separate functions Jonathan Nieder
2010-08-06  3:39         ` [PATCH 2/2] Allow "check-ref-format --branch" from subdirectory Jonathan Nieder
2010-08-06 19:42           ` Junio C Hamano
2010-08-06  4:26       ` [PATCH jn/paginate-fix 0/12] Re: git --paginate: do not commit pager choice too early Nguyen Thai Ngoc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100714225512.GA13636@burratino \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).