summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-08-04 17:50:50 +0200
committerVicent Marti <tanoku@gmail.com>2011-08-18 02:34:08 +0200
commit9cf0f287bb0ece488c9e0a169b3f806a4a9701eb (patch)
treeb68b2b1df2eabeac448a72fffcff49034a094c89
parente1d88030687b2ccd652cfedd97714fb37367bbf9 (diff)
downloadlibgit2-9cf0f287bb0ece488c9e0a169b3f806a4a9701eb.tar.gz
Tell the user where the downloaded packfile is stored
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
-rw-r--r--src/fetch.c4
-rw-r--r--src/transport.c4
-rw-r--r--src/transport.h4
-rw-r--r--src/transport_git.c12
4 files changed, 14 insertions, 10 deletions
diff --git a/src/fetch.c b/src/fetch.c
index b1da7a19f..7e671b799 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 b05833433..1bd0c4e9e 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 ed07b782d..0e0869752 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 b8b1fdd54..871c797c5 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;