]> git.proxmox.com Git - libgit2.git/commitdiff
refspec: short-circuit non-pattern refspecs on transform
authorCarlos Martín Nieto <cmn@dwim.me>
Fri, 4 Jul 2014 15:16:17 +0000 (17:16 +0200)
committerCarlos Martín Nieto <cmn@dwim.me>
Fri, 4 Jul 2014 15:41:40 +0000 (17:41 +0200)
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

index fa60aa7aa88b0c102d8df6a5c7eb737b08309eb7..48d34cd9524549dbd3ce1e374b22c723f4dafc80 100644 (file)
@@ -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);
 }