Skip to content

Commit 7518629

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. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 58e7864 commit 7518629

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

git.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,32 @@ static int run_argv(int *argcp, const char ***argv)
628628
*/
629629
if (!done_alias)
630630
handle_builtin(*argcp, *argv);
631+
else if (get_builtin(**argv)) {
632+
struct argv_array args = ARGV_ARRAY_INIT;
633+
int i;
634+
635+
argv_array_push(&args, "git");
636+
for (i = 0; i < *argcp; i++)
637+
argv_array_push(&args, (*argv)[i]);
638+
639+
if (get_super_prefix())
640+
die("%s doesn't support --super-prefix", args.argv[0]);
641+
642+
if (use_pager == -1)
643+
use_pager = check_pager_config(args.argv[0]);
644+
commit_pager_choice();
645+
646+
trace_argv_printf(args.argv, "trace: exec:");
647+
648+
/*
649+
* if we fail because the command is not found, it is
650+
* OK to return. Otherwise, we just pass along the status code.
651+
*/
652+
i = run_command_v_opt(args.argv, RUN_SILENT_EXEC_FAILURE | RUN_CLEAN_ON_EXIT);
653+
if (i >= 0 || errno != ENOENT)
654+
exit(i);
655+
die("could not execute builtin %s", args.argv[1]);
656+
}
631657

632658
/* .. then try the external ones */
633659
execv_dashed_external(*argv);

0 commit comments

Comments
 (0)