From e5e0eb36ae472a1e10edff888676fe2bebb79e63 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 28 Nov 2016 18:17:49 +0100 Subject: [PATCH] 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 --- git.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/git.c b/git.c index c8fe6637df..549432d404 100644 --- a/git.c +++ b/git.c @@ -622,6 +622,32 @@ static int run_argv(int *argcp, const char ***argv) */ if (!done_alias) handle_builtin(*argcp, *argv); + else if (get_builtin(**argv)) { + struct argv_array args = ARGV_ARRAY_INIT; + int i; + + argv_array_push(&args, "git"); + for (i = 0; i < *argcp; i++) + argv_array_push(&args, (*argv)[i]); + + if (get_super_prefix()) + die("%s doesn't support --super-prefix", args.argv[0]); + + if (use_pager == -1) + use_pager = check_pager_config(args.argv[0]); + commit_pager_choice(); + + trace_argv_printf(args.argv, "trace: exec:"); + + /* + * if we fail because the command is not found, it is + * OK to return. Otherwise, we just pass along the status code. + */ + i = run_command_v_opt(args.argv, RUN_SILENT_EXEC_FAILURE | RUN_CLEAN_ON_EXIT); + if (i >= 0 || errno != ENOENT) + exit(i); + die("could not execute builtin %s", args.argv[1]); + } /* .. then try the external ones */ execv_dashed_external(*argv);