commit - 894e4711ffca9e21b24e567a610d387bd0c31817
commit + a32780aad7a4bc8539de9e7fd39b371f2fe8c346
blob - 699f13578180bc1e991c1ced4b845dda7fa3a633
blob + bc54ae58a9ac550958c259f684367576576d5209
--- lib/got_lib_pack_create.h
+++ lib/got_lib_pack_create.h
* be pre-allocated by the caller with at least SHA1_DIGEST_LENGTH bytes.
*/
const struct got_error *got_pack_create(uint8_t *pack_sha1, int packfd,
- struct got_object_id **theirs, int ntheirs,
+ FILE *delta_cache, struct got_object_id **theirs, int ntheirs,
struct got_object_id **ours, int nours,
struct got_repository *repo, int loose_obj_only, int allow_empty,
got_pack_progress_cb progress_cb, void *progress_arg,
blob - 4b2c3294522e2a180c7438c962c007f6b988e399
blob + a3679a51361ead3fefdf763047f2b5756aaa45ee
--- lib/pack_create.c
+++ lib/pack_create.c
#include "got_path.h"
#include "got_reference.h"
#include "got_repository_admin.h"
-#include "got_opentemp.h"
#include "got_lib_deltify.h"
#include "got_lib_delta.h"
}
const struct got_error *
-got_pack_create(uint8_t *packsha1, int packfd,
+got_pack_create(uint8_t *packsha1, int packfd, FILE *delta_cache,
struct got_object_id **theirs, int ntheirs,
struct got_object_id **ours, int nours,
struct got_repository *repo, int loose_obj_only, int allow_empty,
{
const struct got_error *err;
int delta_cache_fd = -1;
- FILE *delta_cache = NULL;
struct got_object_idset *idset;
struct got_ratelimit rl;
struct got_pack_metavec deltify, reuse;
goto done;
}
- delta_cache_fd = got_opentempfd();
+ delta_cache_fd = dup(fileno(delta_cache));
if (delta_cache_fd == -1) {
- err = got_error_from_errno("got_opentemp");
+ err = got_error_from_errno("dup");
goto done;
}
if (err)
goto done;
- delta_cache = fdopen(delta_cache_fd, "a+");
- if (delta_cache == NULL) {
- err = got_error_from_errno("fdopen");
- goto done;
- }
- delta_cache_fd = -1;
-
if (fseeko(delta_cache, 0L, SEEK_END) == -1) {
err = got_error_from_errno("fseeko");
goto done;
got_object_idset_free(idset);
if (delta_cache_fd != -1 && close(delta_cache_fd) == -1 && err == NULL)
err = got_error_from_errno("close");
- if (delta_cache && fclose(delta_cache) == EOF && err == NULL)
- err = got_error_from_errno("fclose");
return err;
}
blob - 77fcb6b22fcd226378437eda19e4fe0c96478ada
blob + d6850e32bdb9622e2e43e0854788c80dadefc6a9
--- lib/repository_admin.c
+++ lib/repository_admin.c
int nours = 0, ntheirs = 0, packfd = -1, i;
char *tmpfile_path = NULL, *path = NULL, *packfile_path = NULL;
char *sha1_str = NULL;
+ FILE *delta_cache = NULL;
*packfile = NULL;
*pack_hash = NULL;
goto done;
}
+ delta_cache = got_opentemp();
+ if (delta_cache == NULL) {
+ err = got_error_from_errno("got_opentemp");
+ goto done;
+ }
+
err = get_reflist_object_ids(&ours, &nours,
(1 << GOT_OBJ_TYPE_COMMIT) | (1 << GOT_OBJ_TYPE_TAG),
include_refs, repo, cancel_cb, cancel_arg);
goto done;
}
- err = got_pack_create((*pack_hash)->sha1, packfd, theirs, ntheirs,
- ours, nours, repo, loose_obj_only, 0, progress_cb, progress_arg,
- cancel_cb, cancel_arg);
+ err = got_pack_create((*pack_hash)->sha1, packfd, delta_cache,
+ theirs, ntheirs, ours, nours, repo, loose_obj_only, 0,
+ progress_cb, progress_arg, cancel_cb, cancel_arg);
if (err)
goto done;
free(theirs);
if (packfd != -1 && close(packfd) == -1 && err == NULL)
err = got_error_from_errno2("close", packfile_path);
+ if (delta_cache && fclose(delta_cache) == EOF && err == NULL)
+ err = got_error_from_errno("fclose");
if (tmpfile_path && unlink(tmpfile_path) == -1 && err == NULL)
err = got_error_from_errno2("unlink", tmpfile_path);
free(tmpfile_path);
blob - 4393fbc3fe2bb713de61b06db047c3fcff6de871
blob + 999423dd36a6b128a64253ae2261a4d4aadb3796
--- lib/send.c
+++ lib/send.c
struct pack_progress_arg ppa;
uint8_t packsha1[SHA1_DIGEST_LENGTH];
int packfd = -1;
+ FILE *delta_cache = NULL;
TAILQ_INIT(&refs);
TAILQ_INIT(&have_refs);
goto done;
}
+ delta_cache = got_opentemp();
+ if (delta_cache == NULL) {
+ err = got_error_from_errno("got_opentemp");
+ goto done;
+ }
+
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_sendfds) == -1) {
err = got_error_from_errno("socketpair");
goto done;
memset(&ppa, 0, sizeof(ppa));
ppa.progress_cb = progress_cb;
ppa.progress_arg = progress_arg;
- err = got_pack_create(packsha1, packfd, their_ids, ntheirs,
- our_ids, nours, repo, 0, 1, pack_progress, &ppa,
- cancel_cb, cancel_arg);
+ err = got_pack_create(packsha1, packfd, delta_cache,
+ their_ids, ntheirs, our_ids, nours, repo, 0, 1,
+ pack_progress, &ppa, cancel_cb, cancel_arg);
if (err)
goto done;
}
if (packfd != -1 && close(packfd) == -1 && err == NULL)
err = got_error_from_errno("close");
+ if (delta_cache && fclose(delta_cache) == EOF && err == NULL)
+ err = got_error_from_errno("fclose");
if (nsendfd != -1 && close(nsendfd) == -1 && err == NULL)
err = got_error_from_errno("close");
if (npackfd != -1 && close(npackfd) == -1 && err == NULL)