/* DWIM `refspecs` based on `refs` and append the output to `out` */ static int dwim_refspecs(git_vector *out, git_vector *refspecs, git_vector *refs) { size_t i; git_refspec *spec; git_vector_foreach(refspecs, i, spec) { if (git_refspec__dwim_one(out, spec, refs) < 0) return -1; } return 0; }
static int filter_wants(git_remote *remote) { git_remote_head **heads; git_refspec tagspec, head; int error = 0; git_odb *odb; size_t i, heads_len; git_vector_clear(&remote->refs); if ((error = git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true)) < 0) return error; /* * 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. */ if (remote->active_refspecs.length == 0) { if ((error = git_refspec__parse(&head, "HEAD", true)) < 0) goto cleanup; error = git_refspec__dwim_one(&remote->active_refspecs, &head, &remote->refs); git_refspec__free(&head); if (error < 0) goto cleanup; } if (git_repository_odb__weakptr(&odb, remote->repo) < 0) goto cleanup; if (git_remote_ls((const git_remote_head ***)&heads, &heads_len, remote) < 0) goto cleanup; for (i = 0; i < heads_len; i++) { if ((error = maybe_want(remote, heads[i], odb, &tagspec)) < 0) break; } cleanup: git_refspec__free(&tagspec); return error; }