Tell the user where the downloaded packfile is stored Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
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;