]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git.c: ignore pager.* when launching builtin as dashed external
authorMartin Ågren <martin.agren@gmail.com>
Wed, 2 Aug 2017 19:40:55 +0000 (21:40 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Aug 2017 18:08:11 +0000 (11:08 -0700)
When running, e.g., `git -c alias.bar=foo bar`, we expand the alias and
execute `git-foo` as a dashed external. This is true even if git foo is
a builtin. That is on purpose, and is motivated in a comment which was
added in commit 441981bc ("git: simplify environment save/restore
logic", 2016-01-26).

Shortly before we launch a dashed external, and unless we have already
found out whether we should use a pager, we check `pager.foo`. This was
added in commit 92058e4d ("support pager.* for external commands",
2011-08-18). If the dashed external is a builtin, this does not match
that commit's intention and is arguably wrong, since it would be cleaner
if we let the "dashed external builtin" handle `pager.foo`.

This has not mattered in practice, but a recent patch taught `git-tag`
to ignore `pager.tag` under certain circumstances. But, when started
using an alias, it doesn't get the chance to do so, as outlined above.
That recent patch added a test to document this breakage.

Do not check `pager.foo` before launching a builtin as a dashed
external, i.e., if we recognize the name of the external as a builtin.
Change the test to use `test_expect_success`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git.c
t/t7006-pager.sh

diff --git a/git.c b/git.c
index 82ac2a092c63735bf65a3379b4c1f2dc628e3e93..6b6d9f68e1ea010cb951501cab1fdfa82037b878 100644 (file)
--- a/git.c
+++ b/git.c
@@ -559,7 +559,7 @@ static void execv_dashed_external(const char **argv)
        if (get_super_prefix())
                die("%s doesn't support --super-prefix", argv[0]);
 
-       if (use_pager == -1)
+       if (use_pager == -1 && !is_builtin(argv[0]))
                use_pager = check_pager_config(argv[0]);
        commit_pager_choice();
 
index afa03f3b65afd3aea22b967d82a8c4455e7b8808..9128ec5acda3b4b2f568dee50169046a333c4527 100755 (executable)
@@ -201,7 +201,7 @@ test_expect_success TTY 'git tag -a respects --paginate' '
        test -e paginated.out
 '
 
-test_expect_failure TTY 'git tag as alias ignores pager.tag with -a' '
+test_expect_success TTY 'git tag as alias ignores pager.tag with -a' '
        test_when_finished "git tag -d newtag" &&
        rm -f paginated.out &&
        test_terminal git -c pager.tag -c alias.t=tag t -am message newtag &&