Skip to content

Commit 595d59e

Browse files
Martin Ågrengitster
Martin Ågren
authored andcommitted
git.c: ignore pager.* when launching builtin as dashed external
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 441981b ("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 92058e4 ("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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ff1e724 commit 595d59e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ static void execv_dashed_external(const char **argv)
559559
if (get_super_prefix())
560560
die("%s doesn't support --super-prefix", argv[0]);
561561

562-
if (use_pager == -1)
562+
if (use_pager == -1 && !is_builtin(argv[0]))
563563
use_pager = check_pager_config(argv[0]);
564564
commit_pager_choice();
565565

t/t7006-pager.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ test_expect_success TTY 'git tag -a respects --paginate' '
201201
test -e paginated.out
202202
'
203203

204-
test_expect_failure TTY 'git tag as alias ignores pager.tag with -a' '
204+
test_expect_success TTY 'git tag as alias ignores pager.tag with -a' '
205205
test_when_finished "git tag -d newtag" &&
206206
rm -f paginated.out &&
207207
test_terminal git -c pager.tag -c alias.t=tag t -am message newtag &&

0 commit comments

Comments
 (0)