Commit 3028be0723f42f31b1973da9f19f2b0468b11754

Ben Straub 2012-10-16T13:10:27

Add git_indexer_stats field to git_remote Also removing all the *stats parameters from external APIs that don't need them anymore.

diff --git a/include/git2/remote.h b/include/git2/remote.h
index 6471acc..ecd5975 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -186,7 +186,7 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void 
  * @param filename where to store the temporary filename
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_remote_download(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats);
+GIT_EXTERN(int) git_remote_download(git_remote *remote, git_off_t *bytes);
 
 /**
  * Check whether the remote is connected
diff --git a/src/clone.c b/src/clone.c
index 85e69ad..2151856 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -263,7 +263,7 @@ static int setup_remotes_and_fetch(git_repository *repo,
 	if (!git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, origin_url)) {
 		/* Connect and download everything */
 		if (!git_remote_connect(origin, GIT_DIR_FETCH)) {
-			if (!git_remote_download(origin, &bytes, fetch_stats)) {
+			if (!git_remote_download(origin, &bytes)) {
 				/* Create "origin/foo" branches for all remote branches */
 				if (!git_remote_update_tips(origin)) {
 					/* Point HEAD to the same ref as the remote's head */
diff --git a/src/fetch.c b/src/fetch.c
index dc01f67..2429463 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -302,7 +302,7 @@ on_error:
 	return error;
 }
 
-int git_fetch_download_pack(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats)
+int git_fetch_download_pack(git_remote *remote, git_off_t *bytes)
 {
 	git_transport *t = remote->transport;
 
@@ -310,9 +310,9 @@ int git_fetch_download_pack(git_remote *remote, git_off_t *bytes, git_indexer_st
 		return 0;
 
 	if (t->own_logic)
-		return t->download_pack(t, remote->repo, bytes, stats);
+		return t->download_pack(t, remote->repo, bytes, &remote->stats);
 
-	return git_fetch__download_pack(t, remote->repo, bytes, stats);
+	return git_fetch__download_pack(t, remote->repo, bytes, &remote->stats);
 
 }
 
diff --git a/src/fetch.h b/src/fetch.h
index 87bb43b..ae030c6 100644
--- a/src/fetch.h
+++ b/src/fetch.h
@@ -10,7 +10,7 @@
 #include "netops.h"
 
 int git_fetch_negotiate(git_remote *remote);
-int git_fetch_download_pack(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats);
+int git_fetch_download_pack(git_remote *remote, git_off_t *bytes);
 
 int git_fetch__download_pack(git_transport *t, git_repository *repo, git_off_t *bytes, git_indexer_stats *stats);
 int git_fetch_setup_walk(git_revwalk **out, git_repository *repo);
diff --git a/src/remote.c b/src/remote.c
index c47f2d1..82ab22f 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -433,16 +433,16 @@ int git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload)
 	return 0;
 }
 
-int git_remote_download(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats)
+int git_remote_download(git_remote *remote, git_off_t *bytes)
 {
 	int error;
 
-	assert(remote && bytes && stats);
+	assert(remote && bytes);
 
 	if ((error = git_fetch_negotiate(remote)) < 0)
 		return error;
 
-	return git_fetch_download_pack(remote, bytes, stats);
+	return git_fetch_download_pack(remote, bytes);
 }
 
 int git_remote_update_tips(git_remote *remote)
diff --git a/src/remote.h b/src/remote.h
index 05073db..1ba8260 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -25,6 +25,7 @@ struct git_remote {
 	git_transport *transport;
 	git_repository *repo;
 	git_remote_callbacks callbacks;
+	git_indexer_stats stats;
 	unsigned int need_pack:1,
 		download_tags:2, /* There are four possible values */
 		check_cert:1;
diff --git a/tests-clar/network/fetch.c b/tests-clar/network/fetch.c
index 5ff7b0a..1e9a232 100644
--- a/tests-clar/network/fetch.c
+++ b/tests-clar/network/fetch.c
@@ -32,7 +32,6 @@ static void do_fetch(const char *url, int flag, int n)
 {
 	git_remote *remote;
 	git_off_t bytes;
-	git_indexer_stats stats;
 	git_remote_callbacks callbacks;
 
 	memset(&callbacks, 0, sizeof(git_remote_callbacks));
@@ -43,7 +42,7 @@ static void do_fetch(const char *url, int flag, int n)
 	git_remote_set_callbacks(remote, &callbacks);
 	git_remote_set_autotag(remote, flag);
 	cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
-	cl_git_pass(git_remote_download(remote, &bytes, &stats));
+	cl_git_pass(git_remote_download(remote, &bytes));
 	git_remote_disconnect(remote);
 	cl_git_pass(git_remote_update_tips(remote));
 	cl_assert_equal_i(counter, n);