Re: [PATCH v5 1/4] object-name: make get_oid quietly return an error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes:

> diff --git a/object-name.c b/object-name.c
> index 2c751a5352..3138103343 100644
> --- a/object-name.c
> +++ b/object-name.c
> @@ -1081,13 +1081,17 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
>  				 * still fill in the oid with the "old" value,
>  				 * which we can use.
>  				 */
> -			} else {
> +			} else if (!(flags & GET_OID_GENTLY)) {
>  				if (flags & GET_OID_QUIETLY) {
>  					exit(128);
>  				}
>  				die(_("log for '%.*s' only has %d entries"),
>  				    len, str, co_cnt);
>  			}
> +			if (flags & GET_OID_GENTLY) {
> +				free(real_ref);
> +				return -1;
> +			}
>  		}
>  	}
>  

Almost everybody else in this function hits "return -1" after
detecting that it cannot yield a valid object name, and this change
makes the oddball case do the same.

Ideally in a distant past, we might want to remove this _GENTLY
flag, together with the code path that is not so gentle, and adjust
the callers that depend on the current behaviour (which I somehow
doubt--- they need to be prepared to deal with the error return from
other parts of the same function already).  We might need to make it
possible for callers to tell which error condition we got (e.g., did
the input give it a non-existing ref?  did reflog walk run out?),
but these (including to the change to just lose "die" and always go
the GENTLY code path) are totally outside the scope of this series.

Thanks.






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux