commit - 20a7d452fe7df073da75ff371d960625531490cd
commit + 05fa71181ce0b8e193160790042225acf3a73b14
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 - 48f5e3c05388ae62f03ccc8fc6ff150bed79357e
blob + b16beed8949b3ad8f57cae5608658bf8aa5fbc87
--- 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 - 202dbcea10024ab27da81c6bdfc79705de403283
blob + eb6585d23d5e69a331cdd167993f02218ad95c59
--- 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 - 0a2cef9f69032ea6ef32ab3ea69a1124678ca9e7
blob + 981cc70c23c162d4407ab1f084af60b80cbdb0bf
--- 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)