Commit 2cdd5c5752f1dea43cd31be9b75be7f7f5e4eab1

Carlos Martín Nieto 2014-07-03T07:56:31

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.

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;