diff options
author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-09-27 12:04:41 +0200 |
---|---|---|
committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-09-30 11:56:37 +0200 |
commit | 3665ba8eeb4f8b2546517cd208e940b128dd8a46 (patch) | |
tree | f745ef0b1c5187ee1008ae8ee2ae47090443d560 /src | |
parent | 2af1c266415bd2030cdfef8ec170a6c135e12b75 (diff) | |
download | libgit2-3665ba8eeb4f8b2546517cd208e940b128dd8a46.tar.gz |
refspec: add git_refspec__free, remove git_refspec_parse
The latter shouldn't be exposed and isn't used, git_refspec__parse
supersedes it.
Fix a leak in the refspec tests while we're at it.
Diffstat (limited to 'src')
-rw-r--r-- | src/refspec.c | 31 | ||||
-rw-r--r-- | src/refspec.h | 2 | ||||
-rw-r--r-- | src/remote.c | 6 |
3 files changed, 7 insertions, 32 deletions
diff --git a/src/refspec.c b/src/refspec.c index 1265c566c..cd3a528bd 100644 --- a/src/refspec.c +++ b/src/refspec.c @@ -125,35 +125,10 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch) return -1; } -int git_refspec_parse(git_refspec *refspec, const char *str) +void git_refspec__free(git_refspec *refspec) { - char *delim; - - memset(refspec, 0x0, sizeof(git_refspec)); - - if (*str == '+') { - refspec->force = 1; - str++; - } - - delim = strchr(str, ':'); - if (delim == NULL) { - refspec->src = git__strdup(str); - GITERR_CHECK_ALLOC(refspec->src); - return 0; - } - - refspec->src = git__strndup(str, delim - str); - GITERR_CHECK_ALLOC(refspec->src); - - refspec->dst = git__strdup(delim + 1); - if (refspec->dst == NULL) { - git__free(refspec->src); - refspec->src = NULL; - return -1; - } - - return 0; + git__free(refspec->src); + git__free(refspec->dst); } const char *git_refspec_src(const git_refspec *refspec) diff --git a/src/refspec.h b/src/refspec.h index 2f46b3e59..83078151b 100644 --- a/src/refspec.h +++ b/src/refspec.h @@ -25,6 +25,8 @@ int git_refspec__parse( const char *str, bool is_fetch); +void git_refspec__free(git_refspec *refspec); + /** * Transform a reference to its target following the refspec's rules, * and writes the results into a git_buf. diff --git a/src/remote.c b/src/remote.c index 7bc631d45..0ae47c364 100644 --- a/src/remote.c +++ b/src/remote.c @@ -536,10 +536,8 @@ void git_remote_free(git_remote *remote) git_vector_free(&remote->refs); - git__free(remote->fetch.src); - git__free(remote->fetch.dst); - git__free(remote->push.src); - git__free(remote->push.dst); + git_refspec__free(&remote->fetch); + git_refspec__free(&remote->push); git__free(remote->url); git__free(remote->pushurl); git__free(remote->name); |