diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-07-04 17:16:17 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-07-04 17:41:40 +0200 |
commit | 9ed104a8fa9fc28bb29a0ff53c68094696e13aea (patch) | |
tree | dc457f666a70ef8f2e117f92d04e70fe4abbc035 | |
parent | 98ce2318c86b0bf276c016c598f86c4d3566fc69 (diff) | |
download | libgit2-9ed104a8fa9fc28bb29a0ff53c68094696e13aea.tar.gz |
refspec: short-circuit non-pattern refspecs on transform
When transforming a non-pattern refspec, we simply need to copy over the
opposite string. Move that logic up to the wrapper so we can assume a
pattern refspec in the transformation function.
-rw-r--r-- | src/refspec.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/refspec.c b/src/refspec.c index fa60aa7aa..48d34cd95 100644 --- a/src/refspec.c +++ b/src/refspec.c @@ -209,11 +209,21 @@ static int refspec_transform( int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name) { + git_buf_sanitize(out); + + if (!spec->pattern) + return git_buf_puts(out, spec->dst); + return refspec_transform(out, spec->src, spec->dst, name); } int git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *name) { + git_buf_sanitize(out); + + if (!spec->pattern) + return git_buf_puts(out, spec->src); + return refspec_transform(out, spec->dst, spec->src, name); } |