Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-10-04 02:30:01 +0400
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-10-08 04:28:02 +0400
commit517bda196e711b8fdf39735e74112503bbd8fcee (patch)
treeb4ed3c1df9460ebbcfdc2f1485a0f31b6d5a3678 /src/fetch.c
parent4a3b18a62f99c836900c76d480ae33933098461c (diff)
fetch: store FETCH_HEAD
We should always save the remote's HEAD as FETCH_HEAD locally. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/fetch.c b/src/fetch.c
index e8809d0cc..3c3dbcb5b 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -24,7 +24,7 @@ static int filter_wants(git_remote *remote)
git_repository *repo = remote->repo;
const git_refspec *spec;
int error;
- unsigned int i;
+ unsigned int i = 0;
error = git_vector_init(&list, 16, NULL);
if (error < GIT_SUCCESS)
@@ -44,7 +44,24 @@ static int filter_wants(git_remote *remote)
*/
spec = git_remote_fetchspec(remote);
- for (i = 0; i < refs.len; ++i) {
+ /*
+ * We need to handle HEAD separately, as we always want it, but it
+ * probably won't matcht he refspec.
+ */
+ head = refs.heads[0];
+ if (refs.len > 0 && !strcmp(head->name, GIT_HEAD_FILE)) {
+ if (git_odb_exists(repo->db, &head->oid))
+ head->local = 1;
+ else
+ remote->need_pack = 1;
+
+ i = 1;
+ error = git_vector_insert(&list, refs.heads[0]);
+ if (error < GIT_SUCCESS)
+ goto cleanup;
+ }
+
+ for (; i < refs.len; ++i) {
git_remote_head *head = refs.heads[i];
/* If it doesn't match the refpec, we don't want it */