Re: [PATCH 05/35] refspec: convert valid_fetch_refspec to use parse_refspec
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 15, 2018, 09:41 UTC
- Message-ID
- <xmqqa7t18dcw.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180514215626.164960-6-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
> Convert 'valid_fetch_refspec()' to use the new 'parse_refspec()' > function to only parse a single refspec an eliminate an allocation.
s/an/and/, perhaps?
Show 24 quoted lines
> -int valid_fetch_refspec(const char *fetch_refspec_str)
> -{
> - struct refspec_item *refspec;
> -
> - refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);
> - free_refspec(1, refspec);
> - return !!refspec;
> -}
> -
> struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec)
> {
> return parse_refspec_internal(nr_refspec, refspec, 1, 0);
> @@ -242,3 +233,11 @@ void refspec_clear(struct refspec *rs)
>
> rs->fetch = 0;
> }
> +
> +int valid_fetch_refspec(const char *fetch_refspec_str)
> +{
> + struct refspec_item refspec;
> + int ret = parse_refspec(&refspec, fetch_refspec_str, REFSPEC_FETCH);
> + refspec_item_clear(&refspec);
> + return ret;
> +}Makes quite a lot of sense. The function name may eventually want to become parse_refspec_item(), though?