mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-20 13:41:23 +00:00
refspec: introduce git_refspec__serialize()
This commit is contained in:
parent
4fe5520a10
commit
fb39b3a54c
@ -225,3 +225,14 @@ int git_refspec_transform_l(git_buf *out, const git_refspec *spec, const char *n
|
|||||||
return refspec_transform(out, spec->dst, spec->src, name);
|
return refspec_transform(out, spec->dst, spec->src, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int git_refspec__serialize(git_buf *out, const git_refspec *refspec)
|
||||||
|
{
|
||||||
|
if (refspec->force)
|
||||||
|
git_buf_putc(out, '+');
|
||||||
|
|
||||||
|
git_buf_printf(out, "%s:%s",
|
||||||
|
refspec->src != NULL ? refspec->src : "",
|
||||||
|
refspec->dst != NULL ? refspec->dst : "");
|
||||||
|
|
||||||
|
return git_buf_oom(out) == false;
|
||||||
|
}
|
||||||
|
@ -51,4 +51,6 @@ int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *n
|
|||||||
*/
|
*/
|
||||||
int git_refspec_transform_l(git_buf *out, const git_refspec *spec, const char *name);
|
int git_refspec_transform_l(git_buf *out, const git_refspec *spec, const char *name);
|
||||||
|
|
||||||
|
int git_refspec__serialize(git_buf *out, const git_refspec *refspec);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
11
src/remote.c
11
src/remote.c
@ -237,17 +237,14 @@ static int update_config_refspec(
|
|||||||
if (refspec->src == NULL || refspec->dst == NULL)
|
if (refspec->src == NULL || refspec->dst == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
git_buf_printf(
|
if (git_buf_printf(
|
||||||
&name,
|
&name,
|
||||||
"remote.%s.%s",
|
"remote.%s.%s",
|
||||||
remote_name,
|
remote_name,
|
||||||
git_direction == GIT_DIR_FETCH ? "fetch" : "push");
|
git_direction == GIT_DIR_FETCH ? "fetch" : "push") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (refspec->force)
|
if (git_refspec__serialize(&value, refspec) < 0)
|
||||||
git_buf_putc(&value, '+');
|
|
||||||
git_buf_printf(&value, "%s:%s", refspec->src, refspec->dst);
|
|
||||||
|
|
||||||
if (git_buf_oom(&name) || git_buf_oom(&value))
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
error = git_config_set_string(
|
error = git_config_set_string(
|
||||||
|
Loading…
Reference in New Issue
Block a user