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
> @@ -313,6 +348,60 @@ static int apply_stash(int argc, const char **argv,
> const char *prefix)
> +static int drop_stash(int argc, const char **argv, const char *prefix)
> +{
> + const char *commit = NULL;
> + struct stash_info info;
> + struct option options[] = {
> + OPT__QUIET(&quiet, N_("be quiet, only report errors")),
> + OPT_END()
> + };
> +
> + argc = parse_options(argc, argv, prefix, options,
> + git_stash_helper_drop_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);
> +
> + return do_drop_stash(prefix, &info);
> +}