Commit 9cf0f287bb0ece488c9e0a169b3f806a4a9701eb

Carlos Martín Nieto 2011-08-04T17:50:50

Tell the user where the downloaded packfile is stored Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>

diff --git a/src/fetch.c b/src/fetch.c
index b1da7a1..7e671b7 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -199,7 +199,7 @@ cleanup:
 	return error;
 }
 
-int git_fetch_download_pack(git_remote *remote)
+int git_fetch_download_pack(char **out, git_remote *remote)
 {
-	return git_transport_download_pack(remote->transport, remote->repo);
+	return git_transport_download_pack(out, remote->transport, remote->repo);
 }
diff --git a/src/transport.c b/src/transport.c
index b058334..1bd0c4e 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -100,9 +100,9 @@ int git_transport_send_done(struct git_transport *transport)
 	return transport->send_done(transport);
 }
 
-int git_transport_download_pack(git_transport *transport, git_repository *repo)
+int git_transport_download_pack(char **out, git_transport *transport, git_repository *repo)
 {
-	return transport->download_pack(transport, repo);
+	return transport->download_pack(out, transport, repo);
 }
 
 int git_transport_close(git_transport *transport)
diff --git a/src/transport.h b/src/transport.h
index ed07b78..0e08697 100644
--- a/src/transport.h
+++ b/src/transport.h
@@ -75,7 +75,7 @@ struct git_transport {
 	/**
 	 * Download the packfile
 	 */
-	int (*download_pack)(struct git_transport *transport, git_repository *repo);
+	int (*download_pack)(char **out, struct git_transport *transport, git_repository *repo);
 	/**
 	 * Fetch the changes
 	 */
@@ -98,6 +98,6 @@ int git_transport_send_wants(struct git_transport *transport, git_headarray *arr
 int git_transport_send_have(struct git_transport *transport, git_oid *oid);
 int git_transport_send_done(struct git_transport *transport);
 int git_transport_send_flush(struct git_transport *transport);
-int git_transport_download_pack(git_transport *transport, git_repository *repo);
+int git_transport_download_pack(char **out, git_transport *transport, git_repository *repo);
 
 #endif
diff --git a/src/transport_git.c b/src/transport_git.c
index b8b1fdd..871c797 100644
--- a/src/transport_git.c
+++ b/src/transport_git.c
@@ -304,11 +304,11 @@ static int git_send_done(git_transport *transport)
 	return git_pkt_send_done(t->socket);
 }
 
-static int store_pack(gitno_buffer *buf, git_repository *repo)
+static int store_pack(char **out, gitno_buffer *buf, git_repository *repo)
 {
 	git_filebuf file;
 	int error;
-	char path[GIT_PATH_MAX], suff[] = "/objects/pack/pack-XXXX.pack\0";
+	char path[GIT_PATH_MAX], suff[] = "/objects/pack/pack-received\0";
 	off_t off = 0;
 
 	memcpy(path, repo->path_repository, GIT_PATH_MAX - off);
@@ -330,13 +330,17 @@ static int store_pack(gitno_buffer *buf, git_repository *repo)
 		gitno_consume_n(buf, buf->offset);
 	}
 
+	*out = git__strdup(file.path_lock);
+	if (*out == NULL)
+		error = GIT_ENOMEM;
+
 cleanup:
 	if (error < GIT_SUCCESS)
 		git_filebuf_cleanup(&file);
 	return error;
 }
 
-static int git_download_pack(git_transport *transport, git_repository *repo)
+static int git_download_pack(char **out, git_transport *transport, git_repository *repo)
 {
 	transport_git *t = (transport_git *) transport;
 	int s = t->socket, error = GIT_SUCCESS, pack = 0;
@@ -379,7 +383,7 @@ static int git_download_pack(git_transport *transport, git_repository *repo)
 		 * into a packfile
 		 */
 
-		return store_pack(&buf, repo);
+		return store_pack(out, &buf, repo);
 	}
 
 	return error;