remote: store passive refspecs The configured/base fetch refspecs need to be taken into account in order to implement opportunistic remote-tracking branch updates. DWIM them and store them in the struct, but don't do anything with them yet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
diff --git a/src/remote.c b/src/remote.c
index b3e968e..c164db9 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -375,6 +375,7 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
if (git_vector_init(&remote->refs, 32, NULL) < 0 ||
git_vector_init(&remote->refspecs, 2, NULL) < 0 ||
+ git_vector_init(&remote->passive_refspecs, 2, NULL) < 0 ||
git_vector_init(&remote->active_refspecs, 2, NULL) < 0) {
error = -1;
goto cleanup;
@@ -843,9 +844,13 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs)
to_active = &specs;
}
- free_refspecs(&remote->active_refspecs);
+ free_refspecs(&remote->passive_refspecs);
+ if ((error = dwim_refspecs(&remote->passive_refspecs, &remote->refspecs, &refs)) < 0)
+ goto on_error;
+ free_refspecs(&remote->active_refspecs);
error = dwim_refspecs(&remote->active_refspecs, to_active, &refs);
+
git_vector_free(&refs);
free_refspecs(&specs);
git_vector_free(&specs);
@@ -1218,6 +1223,9 @@ void git_remote_free(git_remote *remote)
free_refspecs(&remote->active_refspecs);
git_vector_free(&remote->active_refspecs);
+ free_refspecs(&remote->passive_refspecs);
+ git_vector_free(&remote->passive_refspecs);
+
git__free(remote->url);
git__free(remote->pushurl);
git__free(remote->name);
diff --git a/src/remote.h b/src/remote.h
index f88601e..73c1614 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -23,6 +23,7 @@ struct git_remote {
git_vector refs;
git_vector refspecs;
git_vector active_refspecs;
+ git_vector passive_refspecs;
git_transport_cb transport_cb;
void *transport_cb_payload;
git_transport *transport;