Skip to content

Commit c12cda4

Browse files
ttaylorrgitster
authored andcommitted
builtin/repack.c: write cruft packs to arbitrary locations
In the following commit, a new write_cruft_pack() caller will be added which wants to write a cruft pack to an arbitrary location. Prepare for this by adding a parameter which controls the destination of the cruft pack. For now, provide "packtmp" so that this commit does not change any behavior. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eddad36 commit c12cda4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

builtin/repack.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ static int write_midx_included_packs(struct string_list *include,
662662
}
663663

664664
static int write_cruft_pack(const struct pack_objects_args *args,
665+
const char *destination,
665666
const char *pack_prefix,
666667
const char *cruft_expiration,
667668
struct string_list *names,
@@ -673,8 +674,10 @@ static int write_cruft_pack(const struct pack_objects_args *args,
673674
struct string_list_item *item;
674675
FILE *in, *out;
675676
int ret;
677+
const char *scratch;
678+
int local = skip_prefix(destination, packdir, &scratch);
676679

677-
prepare_pack_objects(&cmd, args, packtmp);
680+
prepare_pack_objects(&cmd, args, destination);
678681

679682
strvec_push(&cmd.args, "--cruft");
680683
if (cruft_expiration)
@@ -714,7 +717,12 @@ static int write_cruft_pack(const struct pack_objects_args *args,
714717
if (line.len != the_hash_algo->hexsz)
715718
die(_("repack: Expecting full hex object ID lines only "
716719
"from pack-objects."));
717-
string_list_append(names, line.buf);
720+
/*
721+
* avoid putting packs written outside of the repository in the
722+
* list of names
723+
*/
724+
if (local)
725+
string_list_append(names, line.buf);
718726
}
719727
fclose(out);
720728

@@ -986,7 +994,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
986994
cruft_po_args.local = po_args.local;
987995
cruft_po_args.quiet = po_args.quiet;
988996

989-
ret = write_cruft_pack(&cruft_po_args, pack_prefix,
997+
ret = write_cruft_pack(&cruft_po_args, packtmp, pack_prefix,
990998
cruft_expiration, &names,
991999
&existing_nonkept_packs,
9921000
&existing_kept_packs);

0 commit comments

Comments
 (0)