Skip to content

Commit 04756bf

Browse files
committed
git: avoid calling aliased builtins via their dashed form
This is one of the few places where Git violates its own deprecation of the dashed form. It is not necessary, either. As of 595d59e (git.c: ignore pager.* when launching builtin as dashed external, 2017-08-02), Git wants to ignore the pager.* config setting when expanding aliases. So let's strip out the check_pager_config(<command-name>) call from the copy-edited code. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent af8e259 commit 04756bf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

git.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,31 @@ static int run_argv(int *argcp, const char ***argv)
604604
*/
605605
if (!done_alias)
606606
handle_builtin(*argcp, *argv);
607+
else if (get_builtin(**argv)) {
608+
struct argv_array args = ARGV_ARRAY_INIT;
609+
int i;
610+
611+
if (get_super_prefix())
612+
die("%s doesn't support --super-prefix", **argv);
613+
614+
commit_pager_choice();
615+
616+
argv_array_push(&args, "git");
617+
for (i = 0; i < *argcp; i++)
618+
argv_array_push(&args, (*argv)[i]);
619+
620+
trace_argv_printf(args.argv, "trace: exec:");
621+
622+
/*
623+
* if we fail because the command is not found, it is
624+
* OK to return. Otherwise, we just pass along the status code.
625+
*/
626+
i = run_command_v_opt(args.argv, RUN_SILENT_EXEC_FAILURE |
627+
RUN_CLEAN_ON_EXIT);
628+
if (i >= 0 || errno != ENOENT)
629+
exit(i);
630+
die("could not execute builtin %s", **argv);
631+
}
607632

608633
/* .. then try the external ones */
609634
execv_dashed_external(*argv);

0 commit comments

Comments
 (0)