On 2022-03-16 at 17:26:28, Junio C Hamano wrote: > > +static int do_import_stash(const char *rev) > > +{ > > + struct object_id oid; > > + size_t nitems = 0, nalloc = 0; > > + struct stash_info *items = NULL; > > + int res = 0; > > + > > + if (get_oid(rev, &oid)) > > + return error(_("not a valid revision: %s"), rev); > > + > > + /* > > + * Walk the commit history, finding each stash entry, and load data into > > + * the array. > > + */ > > + for (size_t i = 0;; i++, nitems++) { > > + int ret; > > + > > + if (nalloc <= i) { > > + size_t new = nalloc * 3 / 2 + 5; > > + items = xrealloc(items, new * sizeof(*items)); > > + nalloc = new; > > + } > > + memset(&items[i], 0, sizeof(*items)); > > + /* We want this to be quiet because it might not exist. */ > > + ret = get_stash_info_for_import(&items[i], &oid); > > The new helper function is not necessary; we can use vanilla > get_stash_info() on the second parent to get the same information, > and we do not really need to keep it in core. We can sanity check > the shape of the imported stash entry right away and discard > everything except for the commit object name. Yes, in the new approach, I think we can do that. We may still need the behavior which doesn't die on error, but I think we can centralize it. -- brian m. carlson (he/him or they/them) Toronto, Ontario, CA
Attachment:
signature.asc
Description: PGP signature