On Sat, Mar 24, 2018 at 1:37 PM, Joel Teichroeb <[email protected]> wrote:
> diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c
> @@ -402,6 +408,36 @@ static int drop_stash(int argc, const char **argv, const
> char *prefix)
> +static int pop_stash(int argc, const char **argv, const char *prefix)
> +{
> + int index = 0;
> + const char *commit = NULL;
> + struct stash_info info;
> + struct option options[] = {
> + OPT__QUIET(&quiet, N_("be quiet, only report errors")),
> + OPT_BOOL(0, "index", &index,
> + N_("attempt to ininstate the index")),
"ininstate"??
> + OPT_END()
> + };
> +
> + argc = parse_options(argc, argv, prefix, options,
> + git_stash_helper_pop_usage, 0);
> +
> + if (argc == 1)
> + commit = argv[0];
Seems fragile. What if there are two arguments?
> + if (get_stash_info(&info, commit))
> + return -1;
> +
> + if (!info.is_stash_ref)
> + return error(_("'%s' is not a stash reference"), commit);
> +
> + if (do_apply_stash(prefix, &info, index))
> + return -1;
> +
> + return do_drop_stash(prefix, &info);
> +}