mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-10 16:12:59 +00:00
remote: create FETCH_HEAD with a refspecless remote
When downloading the default branch due to lack of refspecs, we still need to write out FETCH_HEAD with the tip we downloaded, unfortunately with a format that doesn't match what we already have.
This commit is contained in:
parent
a7382aa28c
commit
968c7d072a
@ -74,6 +74,7 @@ static int fetchhead_ref_write(
|
|||||||
{
|
{
|
||||||
char oid[GIT_OID_HEXSZ + 1];
|
char oid[GIT_OID_HEXSZ + 1];
|
||||||
const char *type, *name;
|
const char *type, *name;
|
||||||
|
int head = 0;
|
||||||
|
|
||||||
assert(file && fetchhead_ref);
|
assert(file && fetchhead_ref);
|
||||||
|
|
||||||
@ -87,11 +88,16 @@ static int fetchhead_ref_write(
|
|||||||
GIT_REFS_TAGS_DIR) == 0) {
|
GIT_REFS_TAGS_DIR) == 0) {
|
||||||
type = "tag ";
|
type = "tag ";
|
||||||
name = fetchhead_ref->ref_name + strlen(GIT_REFS_TAGS_DIR);
|
name = fetchhead_ref->ref_name + strlen(GIT_REFS_TAGS_DIR);
|
||||||
|
} else if (!git__strcmp(fetchhead_ref->ref_name, GIT_HEAD_FILE)) {
|
||||||
|
head = 1;
|
||||||
} else {
|
} else {
|
||||||
type = "";
|
type = "";
|
||||||
name = fetchhead_ref->ref_name;
|
name = fetchhead_ref->ref_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (head)
|
||||||
|
return git_filebuf_printf(file, "%s\t\t%s\n", oid, fetchhead_ref->remote_url);
|
||||||
|
|
||||||
return git_filebuf_printf(file, "%s\t%s\t%s'%s' of %s\n",
|
return git_filebuf_printf(file, "%s\t%s\t%s'%s' of %s\n",
|
||||||
oid,
|
oid,
|
||||||
(fetchhead_ref->is_merge) ? "" : "not-for-merge",
|
(fetchhead_ref->is_merge) ? "" : "not-for-merge",
|
||||||
|
21
src/remote.c
21
src/remote.c
@ -1032,6 +1032,27 @@ int git_remote_update_tips(git_remote *remote)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we have no refspecs, update HEAD -> FETCH_HEAD manually */
|
||||||
|
if (remote->refspecs.length == 0 && refs.length > 0 && git_remote_update_fetchhead(remote)) {
|
||||||
|
git_vector vec;
|
||||||
|
git_refspec headspec;
|
||||||
|
|
||||||
|
if (git_refspec__parse(&headspec, "HEAD", true) < 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (git_vector_init(&vec, 1, NULL) < 0) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (git_vector_insert(&vec, git_vector_get(&refs, 0)) < 0) {
|
||||||
|
git_vector_free(&vec);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = git_remote_write_fetchhead(remote, &headspec, &vec);
|
||||||
|
git_vector_free(&vec);
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
git_refspec__free(&tagspec);
|
git_refspec__free(&tagspec);
|
||||||
git_vector_free(&refs);
|
git_vector_free(&refs);
|
||||||
|
Loading…
Reference in New Issue
Block a user