Hi Paul,
On Mon, 25 Jun 2018, Paul-Sebastian Ungureanu wrote:
> diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c
> index 84a537f39..fbf78249c 100644
> --- a/builtin/stash--helper.c
> +++ b/builtin/stash--helper.c
> @@ -522,6 +528,41 @@ static int drop_stash(int argc, const char **argv, const
> char *prefix)
> return ret;
> }
>
> +static int branch_stash(int argc, const char **argv, const char *prefix)
> +{
> + const char *branch = NULL;
> + int ret;
> + struct argv_array args = ARGV_ARRAY_INIT;
> + struct stash_info info;
> + struct option options[] = {
> + OPT_END()
> + };
> +
> + argc = parse_options(argc, argv, prefix, options,
> + git_stash_helper_branch_usage, 0);
> +
> + if (argc == 0)
> + return error(_("No branch name specified"));
> +
> + branch = argv[0];
> +
> + if (get_stash_info(&info, argc - 1, argv + 1))
> + return -1;
> +
> + argv_array_pushl(&args, "checkout", "-b", NULL);
> + argv_array_push(&args, branch);
> + argv_array_push(&args, oid_to_hex(&info.b_commit));
Why not combine these? _pushl() takes a NULL-terminated list:
argv_array_pushl(&args, "checkout", "-b", branch,
oid_to_hex(&info.b_commit), NULL);
> + ret = cmd_checkout(args.argc, args.argv, prefix);
I guess it is okay to run that, but the cmd_() functions are not *really*
meant to be called this way... Personally, I would be more comfortable
with a `run_command()` here, i.e. with a spawned process, until the time
when checkout.c/checkout.h have learned enough API for a direct call.
Ciao,
Dscho