Re: [PATCH 3/6] object-name: make get_oid quietly return an error
On 2022-03-16 at 16:56:22, Junio C Hamano wrote:
Show 29 quoted lines
> > diff --git a/object-name.c b/object-name.c
> > index 92862eeb1a..daa3ef77ef 100644
> > --- a/object-name.c
> > +++ b/object-name.c
> > @@ -911,13 +911,17 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
> > len, str,
> > show_date(co_time, co_tz, DATE_MODE(RFC2822)));
> > }
> > - } else {
> > + } else if (!(flags & GET_OID_RETURN_FAILURE)) {
> > if (flags & GET_OID_QUIETLY) {
> > exit(128);
> > }
> > die(_("log for '%.*s' only has %d entries"),
> > len, str, co_cnt);
> > }
> > + if (flags & GET_OID_RETURN_FAILURE) {
> > + free(real_ref);
> > + return -1;
> > + }
> > }
>
> So, without the new bit, we used to die loudly or quietly. The new
> bit allows us to return an error to the caller without dying
> ourselves.
>
> You can call the bit _RETURN_ERROR and not to worry about the
> right-alignment above ;-), but better yet, how about calling it
> _GENTLY, which is how we call such a variant of behaviour?--
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA