mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-04 16:42:30 +00:00
refspec: a ref name includes the refs/ prefix
git_refspec_transform_r assumed that the reference name passed would be only a branch or tag name. This is not the case, and we need to take into consideration what's in the refspec's source to know how much of the prefix to ignore.
This commit is contained in:
parent
f25cc58d5c
commit
279afd2a51
@ -107,7 +107,7 @@ int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *n
|
||||
return GIT_SUCCESS;
|
||||
|
||||
git_buf_truncate(out, out->size - 1); /* remove trailing '*' */
|
||||
git_buf_puts(out, name);
|
||||
git_buf_puts(out, name + strlen(spec->src) - 1);
|
||||
|
||||
return git_buf_lasterror(out);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "clar_libgit2.h"
|
||||
#include "buffer.h"
|
||||
#include "refspec.h"
|
||||
|
||||
static git_remote *_remote;
|
||||
static git_repository *_repo;
|
||||
@ -48,3 +50,11 @@ void test_network_remotes__transform(void)
|
||||
cl_git_pass(git_refspec_transform(ref, sizeof(ref), _refspec, "refs/heads/master"));
|
||||
cl_assert(!strcmp(ref, "refs/remotes/test/master"));
|
||||
}
|
||||
|
||||
void test_network_remotes__transform_r(void)
|
||||
{
|
||||
git_buf buf = GIT_BUF_INIT;
|
||||
|
||||
cl_git_pass(git_refspec_transform_r(&buf, _refspec, "refs/heads/master"));
|
||||
cl_assert(!strcmp(git_buf_cstr(&buf), "refs/remotes/test/master"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user