diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2013-10-26 17:35:12 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-11-01 22:47:06 +0100 |
| commit | 968c7d072ae61852564a831706ca5e969a2eb62c (patch) | |
| tree | 2308772f56bad9f12d5bf68736ded00a23de2f4f /src/remote.c | |
| parent | a7382aa28c8a24a4f718eb01574d744330f7a5a9 (diff) | |
| download | libgit2-968c7d072ae61852564a831706ca5e969a2eb62c.tar.gz | |
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.
Diffstat (limited to 'src/remote.c')
| -rw-r--r-- | src/remote.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c index 3528b1c46..2b611aabc 100644 --- a/src/remote.c +++ b/src/remote.c @@ -1032,6 +1032,27 @@ int git_remote_update_tips(git_remote *remote) 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: git_refspec__free(&tagspec); git_vector_free(&refs); |
