From: Eric Sunshine Date: Sun, 25 Mar 2018 06:49:24 GMT Subject: Re: [PATCH 3/4] stash: convert drop and clear to builtin Message-ID: In-Reply-To: <20180324173707.17699-4-joel@teichroeb.net> On Sat, Mar 24, 2018 at 1:37 PM, Joel Teichroeb 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); > +}