fixup! git: avoid calling aliased builtins via their dashed form

When copy-pasting from execv_dashed_external(), the array index was
left unchanged even if we now have an array with `git` shifted in.

Instead of adjusting the array index, simply use the original array.

While at it, also reorder the loop until after the potential early
exit.

Pointed out by Akinori Hattori in

https://github.com/git-for-windows/git/issues/1077#issuecomment-283905530

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2017-03-03 17:02:57 +01:00
parent ce4c6ca554
commit 7503ca808a

19
git.c
View File

@@ -628,27 +628,28 @@ static int run_argv(int *argcp, const char ***argv)
struct argv_array args = ARGV_ARRAY_INIT;
int i;
if (get_super_prefix())
die("%s doesn't support --super-prefix", **argv);
if (use_pager == -1)
use_pager = check_pager_config(**argv);
commit_pager_choice();
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);
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]);
die("could not execute builtin %s", **argv);
}
/* .. then try the external ones */