From 0aa6b7e652a43d65c80e5a54aafc174476a3441c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 4 Jul 2014 17:16:17 +0200 Subject: 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. --- src/refspec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/refspec.c b/src/refspec.c index fa60aa7a..48d34cd9 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); } -- cgit v1.2.1