]> git.proxmox.com Git - libgit2.git/commitdiff
Check that the refspec matches before modifying the out buffer
authorJacques Germishuys <jacquesg@striata.com>
Thu, 21 Aug 2014 16:53:43 +0000 (18:53 +0200)
committerJacques Germishuys <jacquesg@striata.com>
Thu, 21 Aug 2014 16:53:43 +0000 (18:53 +0200)
src/refspec.c

index 8689769f397c4b71e8bea0e22234306ea10351c3..9f0df35a76a04cecabff8bb6651fd0549d936d13 100644 (file)
@@ -226,14 +226,14 @@ int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *nam
        assert(out && spec && name);
        git_buf_sanitize(out);
 
-       if (!spec->pattern)
-               return git_buf_puts(out, spec->dst);
-
        if (!git_refspec_src_matches(spec, name)) {
                giterr_set(GITERR_INVALID, "ref '%s' doesn't match the source", name);
                return -1;
        }
 
+       if (!spec->pattern)
+               return git_buf_puts(out, spec->dst);
+
        return refspec_transform(out, spec->src, spec->dst, name);
 }
 
@@ -242,14 +242,14 @@ int git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *na
        assert(out && spec && name);
        git_buf_sanitize(out);
 
-       if (!spec->pattern)
-               return git_buf_puts(out, spec->src);
-
        if (!git_refspec_dst_matches(spec, name)) {
                giterr_set(GITERR_INVALID, "ref '%s' doesn't match the destination", name);
                return -1;
        }
 
+       if (!spec->pattern)
+               return git_buf_puts(out, spec->src);
+
        return refspec_transform(out, spec->dst, spec->src, name);
 }