summaryrefslogtreecommitdiff
path: root/src/fetch.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2011-10-09 12:09:57 -0700
committerVicent Martí <tanoku@gmail.com>2011-10-09 12:09:57 -0700
commit6aac5afb6d74a016a4066612d99c5a58dea46b40 (patch)
treee2b511c6f202e530879bb2d6800b0e4e5186ad34 /src/fetch.c
parent5a1d2b2a1792b5ad5d3fcb0561fc58b04523ecbc (diff)
parent517bda196e711b8fdf39735e74112503bbd8fcee (diff)
downloadlibgit2-6aac5afb6d74a016a4066612d99c5a58dea46b40.tar.gz
Merge pull request #444 from carlosmn/fetch-fixes
A couple of fetch fixes
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/fetch.c b/src/fetch.c
index 1bb896870..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)
@@ -36,13 +36,32 @@ static int filter_wants(git_remote *remote)
goto cleanup;
}
+ /*
+ * The fetch refspec can be NULL, and what this means is that the
+ * user didn't specify one. This is fine, as it means that we're
+ * not interested in any particular branch but just the remote's
+ * HEAD, which will be stored in FETCH_HEAD after the fetch.
+ */
spec = git_remote_fetchspec(remote);
- if (spec == NULL) {
- error = git__throw(GIT_ERROR, "The remote has no fetchspec");
- goto cleanup;
+
+ /*
+ * 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 = 0; i < refs.len; ++i) {
+ for (; i < refs.len; ++i) {
git_remote_head *head = refs.heads[i];
/* If it doesn't match the refpec, we don't want it */