diff options
Diffstat (limited to 'src/refspec.c')
| -rw-r--r-- | src/refspec.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/refspec.c b/src/refspec.c index 77c58c84e..8689769f3 100644 --- a/src/refspec.c +++ b/src/refspec.c @@ -223,21 +223,33 @@ static int refspec_transform( int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name) { - git_buf_sanitize(out); + 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; + } + 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); + 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; + } + return refspec_transform(out, spec->dst, spec->src, name); } |
