Commit 9cf0f287 by Carlos Martín Nieto Committed by Vicent Marti

Tell the user where the downloaded packfile is stored

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
parent e1d88030
...@@ -199,7 +199,7 @@ cleanup: ...@@ -199,7 +199,7 @@ cleanup:
return error; 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);
} }
...@@ -100,9 +100,9 @@ int git_transport_send_done(struct git_transport *transport) ...@@ -100,9 +100,9 @@ int git_transport_send_done(struct git_transport *transport)
return transport->send_done(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) int git_transport_close(git_transport *transport)
......
...@@ -75,7 +75,7 @@ struct git_transport { ...@@ -75,7 +75,7 @@ struct git_transport {
/** /**
* Download the packfile * 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 * Fetch the changes
*/ */
...@@ -98,6 +98,6 @@ int git_transport_send_wants(struct git_transport *transport, git_headarray *arr ...@@ -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_have(struct git_transport *transport, git_oid *oid);
int git_transport_send_done(struct git_transport *transport); int git_transport_send_done(struct git_transport *transport);
int git_transport_send_flush(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 #endif
...@@ -304,11 +304,11 @@ static int git_send_done(git_transport *transport) ...@@ -304,11 +304,11 @@ static int git_send_done(git_transport *transport)
return git_pkt_send_done(t->socket); 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; git_filebuf file;
int error; 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; off_t off = 0;
memcpy(path, repo->path_repository, GIT_PATH_MAX - off); memcpy(path, repo->path_repository, GIT_PATH_MAX - off);
...@@ -330,13 +330,17 @@ static int store_pack(gitno_buffer *buf, git_repository *repo) ...@@ -330,13 +330,17 @@ static int store_pack(gitno_buffer *buf, git_repository *repo)
gitno_consume_n(buf, buf->offset); gitno_consume_n(buf, buf->offset);
} }
*out = git__strdup(file.path_lock);
if (*out == NULL)
error = GIT_ENOMEM;
cleanup: cleanup:
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
git_filebuf_cleanup(&file); git_filebuf_cleanup(&file);
return error; 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; transport_git *t = (transport_git *) transport;
int s = t->socket, error = GIT_SUCCESS, pack = 0; int s = t->socket, error = GIT_SUCCESS, pack = 0;
...@@ -379,7 +383,7 @@ static int git_download_pack(git_transport *transport, git_repository *repo) ...@@ -379,7 +383,7 @@ static int git_download_pack(git_transport *transport, git_repository *repo)
* into a packfile * into a packfile
*/ */
return store_pack(&buf, repo); return store_pack(out, &buf, repo);
} }
return error; return error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment