diff options
author | Brandon Williams <bmwill@google.com> | 2018-05-16 15:57:52 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-18 06:19:42 +0900 |
commit | c8fa9efe3a8765f44eacc5b0e114053a0297dfff (patch) | |
tree | 7aa5b896ab8021b31b418d256a0fe5d7c81e0b87 /refspec.c | |
parent | 6d4c05785946e302e611be9ac1f5ca0b5ada9214 (diff) | |
download | git-c8fa9efe3a8765f44eacc5b0e114053a0297dfff.tar.gz |
refspec: convert valid_fetch_refspec to use parse_refspec
Convert 'valid_fetch_refspec()' to use the new 'parse_refspec()'
function to only parse a single refspec and eliminate an allocation.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refspec.c')
-rw-r--r-- | refspec.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -146,15 +146,6 @@ static struct refspec_item *parse_refspec_internal(int nr_refspec, const char ** die("Invalid refspec '%s'", refspec[i]); } -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; +} |