commit - bcfa81c7d30bcafdd71a03b1ca679ad735fd0a80
commit + c7a4fcc8bebad9dc0bd1183fec3bd405dd4ebc57
blob - e11b3a0b3586e7aac0c6955aac2096e7dc6d7fe6
blob + 5278c5830ad6b4af4c8d43dbbe466b6a4851dd25
--- gotadmin/gotadmin.1
+++ gotadmin/gotadmin.1
.El
.It Xo
.Cm pack
-.Op Fl aq
+.Op Fl aDq
.Op Fl r Ar repository-path
.Op Fl x Ar reference
.Op Ar reference ...
Add objects to the generated pack file even if they are already packed
in a different pack file.
Unless this option is specified, only loose objects will be added.
+.It Fl D
+Force the use of ref-delta representation for deltified objects.
+If this option is not specified, offset-deltas will be used to represent
+deltified objects.
.It Fl q
Suppress progress reporting output.
.It Fl r Ar repository-path
blob - 158bbdc93cdc3b2264d3efa8d639edde028f21d8
blob + 5b9d8b5a6a7fbe003142391b78a0d10c4d9776a8
--- gotadmin/gotadmin.c
+++ gotadmin/gotadmin.c
__dead static void
usage_pack(void)
{
- fprintf(stderr, "usage: %s pack [-aq] [-r repository-path] "
+ fprintf(stderr, "usage: %s pack [-aDq] [-r repository-path] "
"[-x reference] [reference ...]\n", getprogname());
exit(1);
}
const struct got_error *error = NULL;
char *repo_path = NULL;
struct got_repository *repo = NULL;
- int ch, i, loose_obj_only = 1, verbosity = 0;
+ int ch, i, loose_obj_only = 1, force_refdelta = 0, verbosity = 0;
struct got_object_id *pack_hash = NULL;
char *id_str = NULL;
struct got_pack_progress_arg ppa;
err(1, "pledge");
#endif
- while ((ch = getopt(argc, argv, "aqr:x:")) != -1) {
+ while ((ch = getopt(argc, argv, "aDqr:x:")) != -1) {
switch (ch) {
case 'a':
loose_obj_only = 0;
break;
+ case 'D':
+ force_refdelta = 1;
+ break;
case 'q':
verbosity = -1;
break;
error = got_repo_pack_objects(&packfile, &pack_hash,
&include_refs, &exclude_refs, repo, loose_obj_only,
- pack_progress, &ppa, check_cancelled, NULL);
+ force_refdelta, pack_progress, &ppa, check_cancelled, NULL);
if (error) {
if (ppa.printed_something)
printf("\n");
blob - 2caf2a94d4ed262a215863f07c9e967a8f052cc3
blob + 5ddd50191b8acfb903877b148bb856de99014b07
--- include/got_repository_admin.h
+++ include/got_repository_admin.h
got_repo_pack_objects(FILE **packfile, struct got_object_id **pack_hash,
struct got_reflist_head *include_refs,
struct got_reflist_head *exclude_refs, struct got_repository *repo,
- int loose_obj_only,
+ int loose_obj_only, int force_refdelta,
got_pack_progress_cb progress_cb, void *progress_arg,
got_cancel_cb cancel_cb, void *cancel_arg);
blob - 7a3c6579c0c3c5ab813f5c5cdb1093a791ac08b4
blob + a46287669ce58c4c526c341b77350db16c5fa714
--- lib/got_lib_pack_create.h
+++ lib/got_lib_pack_create.h
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,
+ int force_refdelta, got_pack_progress_cb progress_cb, void *progress_arg,
struct got_ratelimit *, got_cancel_cb cancel_cb, void *cancel_arg);
const struct got_error *
blob - 0dda4f95f2b3f8b16523c768cd55fa04de120f90
blob + 95d714f2a51d5cc296d631de484ea56651cc4c23
--- lib/pack_create.c
+++ lib/pack_create.c
}
static const struct got_error *
-deltahdr(off_t *packfile_size, SHA1_CTX *ctx, int packfd,
+deltahdr(off_t *packfile_size, SHA1_CTX *ctx, int packfd, int force_refdelta,
struct got_pack_meta *m)
{
const struct got_error *err;
char buf[32];
int nh;
- if (m->prev->off != 0) {
+ if (m->prev->off != 0 && !force_refdelta) {
err = packhdr(&nh, buf, sizeof(buf),
GOT_OBJ_TYPE_OFFSET_DELTA, m->delta_len);
if (err)
write_packed_object(off_t *packfile_size, int packfd,
FILE *delta_cache, uint8_t *delta_cache_map, size_t delta_cache_size,
struct got_pack_meta *m, int *outfd, SHA1_CTX *ctx,
- struct got_repository *repo)
+ struct got_repository *repo, int force_refdelta)
{
const struct got_error *err = NULL;
struct got_deflate_checksum csum;
got_object_raw_close(raw);
raw = NULL;
} else if (m->delta_buf) {
- err = deltahdr(packfile_size, ctx, packfd, m);
+ err = deltahdr(packfile_size, ctx, packfd, force_refdelta, m);
if (err)
goto done;
err = hwrite(packfd, m->delta_buf,
free(m->delta_buf);
m->delta_buf = NULL;
} else if (delta_cache_map) {
- err = deltahdr(packfile_size, ctx, packfd, m);
+ err = deltahdr(packfile_size, ctx, packfd, force_refdelta, m);
if (err)
goto done;
err = hcopy_mmap(delta_cache_map, delta_offset,
err = got_error_from_errno("fseeko");
goto done;
}
- err = deltahdr(packfile_size, ctx, packfd, m);
+ err = deltahdr(packfile_size, ctx, packfd, force_refdelta, m);
if (err)
goto done;
err = hcopy(delta_cache, packfd,
FILE *delta_cache, struct got_pack_meta **deltify, int ndeltify,
struct got_pack_meta **reuse, int nreuse,
int ncolored, int nfound, int ntrees, int nours,
- struct got_repository *repo,
+ struct got_repository *repo, int force_refdelta,
got_pack_progress_cb progress_cb, void *progress_arg,
struct got_ratelimit *rl,
got_cancel_cb cancel_cb, void *cancel_arg)
m = deltify[i];
err = write_packed_object(&packfile_size, packfd,
delta_cache, delta_cache_map, delta_cache_size,
- m, &outfd, &ctx, repo);
+ m, &outfd, &ctx, repo, force_refdelta);
if (err)
goto done;
}
m = reuse[i];
err = write_packed_object(&packfile_size, packfd,
packfile, reuse_pack->map, reuse_pack->filesize,
- m, &outfd, &ctx, repo);
+ m, &outfd, &ctx, repo, force_refdelta);
if (err)
goto done;
}
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,
+ int force_refdelta, got_pack_progress_cb progress_cb, void *progress_arg,
struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err;
err = genpack(packsha1, packfd, reuse_pack, delta_cache, deltify.meta,
deltify.nmeta, reuse.meta, reuse.nmeta, ncolored, nfound, ntrees,
- nours, repo, progress_cb, progress_arg, rl,
+ nours, repo, force_refdelta, progress_cb, progress_arg, rl,
cancel_cb, cancel_arg);
if (err)
goto done;
blob - 0be05225c5acde90af06fcbe60d29ec6a8044bbe
blob + 2cf10c7098742c7f5001d798dd72d648ca497c54
--- lib/repository_admin.c
+++ lib/repository_admin.c
got_repo_pack_objects(FILE **packfile, struct got_object_id **pack_hash,
struct got_reflist_head *include_refs,
struct got_reflist_head *exclude_refs, struct got_repository *repo,
- int loose_obj_only,
+ int loose_obj_only, int force_refdelta,
got_pack_progress_cb progress_cb, void *progress_arg,
got_cancel_cb cancel_cb, void *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, &rl, cancel_cb, cancel_arg);
+ theirs, ntheirs, ours, nours, repo, loose_obj_only,
+ 0, force_refdelta, progress_cb, progress_arg, &rl,
+ cancel_cb, cancel_arg);
if (err)
goto done;
blob - ec59732b5d47bf06ab52a0c1cced9366c7816e51
blob + 0d7e06e0cebfa5b52ece66ddf1829aeb6b724bde
--- lib/send.c
+++ lib/send.c
ppa.progress_cb = progress_cb;
ppa.progress_arg = progress_arg;
err = got_pack_create(packsha1, packfd, delta_cache,
- their_ids, ntheirs, our_ids, nours, repo, 0, 1,
+ their_ids, ntheirs, our_ids, nours, repo, 0, 0, 1,
pack_progress, &ppa, &rl, cancel_cb, cancel_arg);
if (err)
goto done;