diff options
Diffstat (limited to 'src/refspec.c')
-rw-r--r-- | src/refspec.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/refspec.c b/src/refspec.c index 62683e7b7..7ce32ba14 100644 --- a/src/refspec.c +++ b/src/refspec.c @@ -93,3 +93,21 @@ int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, con return GIT_SUCCESS; } + +int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *name) +{ + if (git_buf_sets(out, spec->dst) < GIT_SUCCESS) + return git_buf_lasterror(out); + + /* + * No '*' at the end means that it's mapped to one specific local + * branch, so no actual transformation is needed. + */ + if (out->size > 0 && out->ptr[out->size - 1] != '*') + return GIT_SUCCESS; + + git_buf_truncate(out, out->size - 1); /* remove trailing '*' */ + git_buf_puts(out, name); + + return git_buf_lasterror(out); +} |