summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Germishuys <jacquesg@striata.com>2014-08-21 18:53:43 +0200
committerJacques Germishuys <jacquesg@striata.com>2014-08-21 18:53:43 +0200
commit8f6073f63e42c2a3ff3b6fbb20729c7a911be30f (patch)
tree51199dd34ee0042a5765bfcb360f7b2de45ae6c2
parent4e53c28096f4b04ab9b573fc594a538f51e10049 (diff)
downloadlibgit2-8f6073f63e42c2a3ff3b6fbb20729c7a911be30f.tar.gz
Check that the refspec matches before modifying the out buffer
-rw-r--r--src/refspec.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/refspec.c b/src/refspec.c
index 8689769f3..9f0df35a7 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -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);
}