summaryrefslogtreecommitdiff
path: root/src/fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/fetch.c b/src/fetch.c
index f447248c5..f9e15b232 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -115,25 +115,31 @@ int git_fetch_download_pack(char **out, git_remote *remote)
}
/* Receiving data from a socket and storing it is pretty much the same for git and HTTP */
-int git_fetch__download_pack(char **out, const char *buffered, size_t buffered_size,
- GIT_SOCKET fd, git_repository *repo)
+int git_fetch__download_pack(
+ char **out,
+ const char *buffered,
+ size_t buffered_size,
+ GIT_SOCKET fd,
+ git_repository *repo)
{
git_filebuf file = GIT_FILEBUF_INIT;
int error;
- char buff[1024], path[GIT_PATH_MAX];
+ char buff[1024];
+ git_buf path = GIT_BUF_INIT;
static const char suff[] = "/objects/pack/pack-received";
gitno_buffer buf;
-
- git_path_join(path, repo->path_repository, suff);
-
gitno_buffer_setup(&buf, buff, sizeof(buff), fd);
if (memcmp(buffered, "PACK", strlen("PACK"))) {
return git__throw(GIT_ERROR, "The pack doesn't start with the signature");
}
- error = git_filebuf_open(&file, path, GIT_FILEBUF_TEMPORARY);
+ error = git_buf_joinpath(&path, repo->path_repository, suff);
+ if (error < GIT_SUCCESS)
+ goto cleanup;
+
+ error = git_filebuf_open(&file, path.ptr, GIT_FILEBUF_TEMPORARY);
if (error < GIT_SUCCESS)
goto cleanup;
@@ -166,7 +172,7 @@ int git_fetch__download_pack(char **out, const char *buffered, size_t buffered_s
cleanup:
if (error < GIT_SUCCESS)
git_filebuf_cleanup(&file);
+ git_buf_free(&path);
return error;
-
}