]> git.ipfire.org Git - thirdparty/git.git/blame - builtin/repack.c
Merge branch 'bw/format-patch-o-create-leading-dirs'
[thirdparty/git.git] / builtin / repack.c
CommitLineData
a1bbc6c0
SB
1#include "builtin.h"
2#include "cache.h"
b2141fc1 3#include "config.h"
a1bbc6c0
SB
4#include "dir.h"
5#include "parse-options.h"
6#include "run-command.h"
7#include "sigchain.h"
8#include "strbuf.h"
9#include "string-list.h"
10#include "argv-array.h"
525e18c0 11#include "midx.h"
5d19e813 12#include "packfile.h"
36f0f344 13#include "object-store.h"
b14ed5ad 14#include "promisor-remote.h"
a1bbc6c0
SB
15
16static int delta_base_offset = 1;
ee34a2be 17static int pack_kept_objects = -1;
36eba032 18static int write_bitmaps = -1;
16d75fa4 19static int use_delta_islands;
a1bbc6c0
SB
20static char *packdir, *packtmp;
21
22static const char *const git_repack_usage[] = {
9c9b4f2f 23 N_("git repack [<options>]"),
a1bbc6c0
SB
24 NULL
25};
26
1c409a70
DT
27static const char incremental_bitmap_conflict_error[] = N_(
28"Incremental repacks are incompatible with bitmap indexes. Use\n"
29"--no-write-bitmap-index or disable the pack.writebitmaps configuration."
30);
31
32
a1bbc6c0
SB
33static int repack_config(const char *var, const char *value, void *cb)
34{
35 if (!strcmp(var, "repack.usedeltabaseoffset")) {
36 delta_base_offset = git_config_bool(var, value);
37 return 0;
38 }
ee34a2be
JK
39 if (!strcmp(var, "repack.packkeptobjects")) {
40 pack_kept_objects = git_config_bool(var, value);
41 return 0;
42 }
71d76cb4
JK
43 if (!strcmp(var, "repack.writebitmaps") ||
44 !strcmp(var, "pack.writebitmaps")) {
d078d85b 45 write_bitmaps = git_config_bool(var, value);
3198b89f
JK
46 return 0;
47 }
16d75fa4
JK
48 if (!strcmp(var, "repack.usedeltaislands")) {
49 use_delta_islands = git_config_bool(var, value);
50 return 0;
51 }
a1bbc6c0
SB
52 return git_default_config(var, value, cb);
53}
54
55/*
56 * Remove temporary $GIT_OBJECT_DIRECTORY/pack/.tmp-$$-pack-* files.
57 */
58static void remove_temporary_files(void)
59{
60 struct strbuf buf = STRBUF_INIT;
61 size_t dirlen, prefixlen;
62 DIR *dir;
63 struct dirent *e;
64
65 dir = opendir(packdir);
66 if (!dir)
67 return;
68
69 /* Point at the slash at the end of ".../objects/pack/" */
70 dirlen = strlen(packdir) + 1;
71 strbuf_addstr(&buf, packtmp);
72 /* Hold the length of ".tmp-%d-pack-" */
73 prefixlen = buf.len - dirlen;
74
75 while ((e = readdir(dir))) {
76 if (strncmp(e->d_name, buf.buf + dirlen, prefixlen))
77 continue;
78 strbuf_setlen(&buf, dirlen);
79 strbuf_addstr(&buf, e->d_name);
80 unlink(buf.buf);
81 }
82 closedir(dir);
83 strbuf_release(&buf);
84}
85
86static void remove_pack_on_signal(int signo)
87{
88 remove_temporary_files();
89 sigchain_pop(signo);
90 raise(signo);
91}
92
93/*
94 * Adds all packs hex strings to the fname list, which do not
5d19e813 95 * have a corresponding .keep file. These packs are not to
0c16cd49 96 * be kept if we are going to pack everything into one file.
a1bbc6c0 97 */
ed7e5fc3
NTND
98static void get_non_kept_pack_filenames(struct string_list *fname_list,
99 const struct string_list *extra_keep)
a1bbc6c0
SB
100{
101 DIR *dir;
102 struct dirent *e;
103 char *fname;
a1bbc6c0
SB
104
105 if (!(dir = opendir(packdir)))
106 return;
107
108 while ((e = readdir(dir)) != NULL) {
26936bfd 109 size_t len;
ed7e5fc3
NTND
110 int i;
111
112 for (i = 0; i < extra_keep->nr; i++)
113 if (!fspathcmp(e->d_name, extra_keep->items[i].string))
114 break;
115 if (extra_keep->nr > 0 && i < extra_keep->nr)
116 continue;
117
26936bfd 118 if (!strip_suffix(e->d_name, ".pack", &len))
a1bbc6c0
SB
119 continue;
120
a1bbc6c0
SB
121 fname = xmemdupz(e->d_name, len);
122
5d19e813 123 if (!file_exists(mkpath("%s/%s.keep", packdir, fname)))
a1bbc6c0
SB
124 string_list_append_nodup(fname_list, fname);
125 else
126 free(fname);
127 }
128 closedir(dir);
129}
130
131static void remove_redundant_pack(const char *dir_name, const char *base_name)
132{
a1bbc6c0 133 struct strbuf buf = STRBUF_INIT;
8434e85d
DS
134 strbuf_addf(&buf, "%s/%s.pack", dir_name, base_name);
135 unlink_pack_path(buf.buf, 1);
a1bbc6c0
SB
136 strbuf_release(&buf);
137}
138
2b958e79
JT
139struct pack_objects_args {
140 const char *window;
141 const char *window_memory;
142 const char *depth;
143 const char *threads;
144 const char *max_pack_size;
145 int no_reuse_delta;
146 int no_reuse_object;
147 int quiet;
148 int local;
149};
150
151static void prepare_pack_objects(struct child_process *cmd,
152 const struct pack_objects_args *args)
153{
154 argv_array_push(&cmd->args, "pack-objects");
155 if (args->window)
156 argv_array_pushf(&cmd->args, "--window=%s", args->window);
157 if (args->window_memory)
158 argv_array_pushf(&cmd->args, "--window-memory=%s", args->window_memory);
159 if (args->depth)
160 argv_array_pushf(&cmd->args, "--depth=%s", args->depth);
161 if (args->threads)
162 argv_array_pushf(&cmd->args, "--threads=%s", args->threads);
163 if (args->max_pack_size)
164 argv_array_pushf(&cmd->args, "--max-pack-size=%s", args->max_pack_size);
165 if (args->no_reuse_delta)
166 argv_array_pushf(&cmd->args, "--no-reuse-delta");
167 if (args->no_reuse_object)
168 argv_array_pushf(&cmd->args, "--no-reuse-object");
169 if (args->local)
170 argv_array_push(&cmd->args, "--local");
171 if (args->quiet)
172 argv_array_push(&cmd->args, "--quiet");
173 if (delta_base_offset)
174 argv_array_push(&cmd->args, "--delta-base-offset");
175 argv_array_push(&cmd->args, packtmp);
176 cmd->git_cmd = 1;
177 cmd->out = -1;
178}
179
5d19e813
JT
180/*
181 * Write oid to the given struct child_process's stdin, starting it first if
182 * necessary.
183 */
184static int write_oid(const struct object_id *oid, struct packed_git *pack,
185 uint32_t pos, void *data)
186{
187 struct child_process *cmd = data;
188
189 if (cmd->in == -1) {
190 if (start_command(cmd))
c83d950e 191 die(_("could not start pack-objects to repack promisor objects"));
5d19e813
JT
192 }
193
dd336a55 194 xwrite(cmd->in, oid_to_hex(oid), the_hash_algo->hexsz);
5d19e813
JT
195 xwrite(cmd->in, "\n", 1);
196 return 0;
197}
198
199static void repack_promisor_objects(const struct pack_objects_args *args,
200 struct string_list *names)
201{
202 struct child_process cmd = CHILD_PROCESS_INIT;
203 FILE *out;
204 struct strbuf line = STRBUF_INIT;
205
206 prepare_pack_objects(&cmd, args);
207 cmd.in = -1;
208
209 /*
210 * NEEDSWORK: Giving pack-objects only the OIDs without any ordering
211 * hints may result in suboptimal deltas in the resulting pack. See if
212 * the OIDs can be sent with fake paths such that pack-objects can use a
213 * {type -> existing pack order} ordering when computing deltas instead
214 * of a {type -> size} ordering, which may produce better deltas.
215 */
216 for_each_packed_object(write_oid, &cmd,
217 FOR_EACH_OBJECT_PROMISOR_ONLY);
218
219 if (cmd.in == -1)
220 /* No packed objects; cmd was never started */
221 return;
222
223 close(cmd.in);
224
225 out = xfdopen(cmd.out, "r");
226 while (strbuf_getline_lf(&line, out) != EOF) {
227 char *promisor_name;
228 int fd;
2f0c9e9a 229 if (line.len != the_hash_algo->hexsz)
3813a89f 230 die(_("repack: Expecting full hex object ID lines only from pack-objects."));
5d19e813
JT
231 string_list_append(names, line.buf);
232
233 /*
234 * pack-objects creates the .pack and .idx files, but not the
235 * .promisor file. Create the .promisor file, which is empty.
236 */
237 promisor_name = mkpathdup("%s-%s.promisor", packtmp,
238 line.buf);
239 fd = open(promisor_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
240 if (fd < 0)
c83d950e 241 die_errno(_("unable to create '%s'"), promisor_name);
5d19e813
JT
242 close(fd);
243 free(promisor_name);
244 }
245 fclose(out);
246 if (finish_command(&cmd))
c83d950e 247 die(_("could not finish pack-objects to repack promisor objects"));
5d19e813
JT
248}
249
a1bbc6c0
SB
250#define ALL_INTO_ONE 1
251#define LOOSEN_UNREACHABLE 2
252
253int cmd_repack(int argc, const char **argv, const char *prefix)
254{
42a02d85
JK
255 struct {
256 const char *name;
b77fcd1e 257 unsigned optional:1;
42a02d85
JK
258 } exts[] = {
259 {".pack"},
260 {".idx"},
5cf2741c 261 {".bitmap", 1},
5d19e813 262 {".promisor", 1},
42a02d85 263 };
d3180279 264 struct child_process cmd = CHILD_PROCESS_INIT;
a1bbc6c0 265 struct string_list_item *item;
a1bbc6c0
SB
266 struct string_list names = STRING_LIST_INIT_DUP;
267 struct string_list rollback = STRING_LIST_INIT_NODUP;
268 struct string_list existing_packs = STRING_LIST_INIT_DUP;
269 struct strbuf line = STRBUF_INIT;
ed7e5fc3 270 int i, ext, ret, failed;
a1bbc6c0
SB
271 FILE *out;
272
273 /* variables to be filled by option parsing */
274 int pack_everything = 0;
275 int delete_redundant = 0;
aa8bd519 276 const char *unpack_unreachable = NULL;
905f27b8 277 int keep_unreachable = 0;
ed7e5fc3 278 struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
a1bbc6c0 279 int no_update_server_info = 0;
525e18c0 280 int midx_cleared = 0;
2b958e79 281 struct pack_objects_args po_args = {NULL};
a1bbc6c0
SB
282
283 struct option builtin_repack_options[] = {
284 OPT_BIT('a', NULL, &pack_everything,
285 N_("pack everything in a single pack"), ALL_INTO_ONE),
286 OPT_BIT('A', NULL, &pack_everything,
287 N_("same as -a, and turn unreachable objects loose"),
288 LOOSEN_UNREACHABLE | ALL_INTO_ONE),
289 OPT_BOOL('d', NULL, &delete_redundant,
290 N_("remove redundant packs, and run git-prune-packed")),
2b958e79 291 OPT_BOOL('f', NULL, &po_args.no_reuse_delta,
a1bbc6c0 292 N_("pass --no-reuse-delta to git-pack-objects")),
2b958e79 293 OPT_BOOL('F', NULL, &po_args.no_reuse_object,
a1bbc6c0
SB
294 N_("pass --no-reuse-object to git-pack-objects")),
295 OPT_BOOL('n', NULL, &no_update_server_info,
296 N_("do not run git-update-server-info")),
2b958e79
JT
297 OPT__QUIET(&po_args.quiet, N_("be quiet")),
298 OPT_BOOL('l', "local", &po_args.local,
a1bbc6c0 299 N_("pass --local to git-pack-objects")),
d078d85b 300 OPT_BOOL('b', "write-bitmap-index", &write_bitmaps,
5cf2741c 301 N_("write bitmap index")),
16d75fa4
JK
302 OPT_BOOL('i', "delta-islands", &use_delta_islands,
303 N_("pass --delta-islands to git-pack-objects")),
a1bbc6c0
SB
304 OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"),
305 N_("with -A, do not loosen objects older than this")),
905f27b8
JK
306 OPT_BOOL('k', "keep-unreachable", &keep_unreachable,
307 N_("with -a, repack unreachable objects")),
2b958e79 308 OPT_STRING(0, "window", &po_args.window, N_("n"),
a1bbc6c0 309 N_("size of the window used for delta compression")),
2b958e79 310 OPT_STRING(0, "window-memory", &po_args.window_memory, N_("bytes"),
a1bbc6c0 311 N_("same as the above, but limit memory size instead of entries count")),
2b958e79 312 OPT_STRING(0, "depth", &po_args.depth, N_("n"),
a1bbc6c0 313 N_("limits the maximum delta depth")),
2b958e79 314 OPT_STRING(0, "threads", &po_args.threads, N_("n"),
40bcf318 315 N_("limits the maximum number of threads")),
2b958e79 316 OPT_STRING(0, "max-pack-size", &po_args.max_pack_size, N_("bytes"),
a1bbc6c0 317 N_("maximum size of each packfile")),
ee34a2be
JK
318 OPT_BOOL(0, "pack-kept-objects", &pack_kept_objects,
319 N_("repack objects in packs marked with .keep")),
ed7e5fc3
NTND
320 OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"),
321 N_("do not repack this pack")),
a1bbc6c0
SB
322 OPT_END()
323 };
324
325 git_config(repack_config, NULL);
326
327 argc = parse_options(argc, argv, prefix, builtin_repack_options,
328 git_repack_usage, 0);
329
067fbd41
JK
330 if (delete_redundant && repository_format_precious_objects)
331 die(_("cannot delete packs in a precious-objects repo"));
332
905f27b8
JK
333 if (keep_unreachable &&
334 (unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE)))
335 die(_("--keep-unreachable and -A are incompatible"));
336
73284822 337 if (write_bitmaps < 0) {
25575015 338 if (!(pack_everything & ALL_INTO_ONE) ||
7ff024e7 339 !is_bare_repository())
25575015 340 write_bitmaps = 0;
73284822 341 }
ee34a2be 342 if (pack_kept_objects < 0)
7ff024e7 343 pack_kept_objects = write_bitmaps > 0;
ee34a2be 344
1c409a70
DT
345 if (write_bitmaps && !(pack_everything & ALL_INTO_ONE))
346 die(_(incremental_bitmap_conflict_error));
347
a1bbc6c0
SB
348 packdir = mkpathdup("%s/pack", get_object_directory());
349 packtmp = mkpathdup("%s/.tmp-%d-pack", packdir, (int)getpid());
350
351 sigchain_push_common(remove_pack_on_signal);
352
2b958e79
JT
353 prepare_pack_objects(&cmd, &po_args);
354
a2bae2dc 355 argv_array_push(&cmd.args, "--keep-true-parents");
ee34a2be 356 if (!pack_kept_objects)
a2bae2dc 357 argv_array_push(&cmd.args, "--honor-pack-keep");
ed7e5fc3
NTND
358 for (i = 0; i < keep_pack_list.nr; i++)
359 argv_array_pushf(&cmd.args, "--keep-pack=%s",
360 keep_pack_list.items[i].string);
a2bae2dc
RS
361 argv_array_push(&cmd.args, "--non-empty");
362 argv_array_push(&cmd.args, "--all");
363 argv_array_push(&cmd.args, "--reflog");
364 argv_array_push(&cmd.args, "--indexed-objects");
b14ed5ad 365 if (has_promisor_remote())
0c16cd49 366 argv_array_push(&cmd.args, "--exclude-promisor-objects");
25575015 367 if (write_bitmaps > 0)
a2bae2dc 368 argv_array_push(&cmd.args, "--write-bitmap-index");
25575015
JK
369 else if (write_bitmaps < 0)
370 argv_array_push(&cmd.args, "--write-bitmap-index-quiet");
16d75fa4
JK
371 if (use_delta_islands)
372 argv_array_push(&cmd.args, "--delta-islands");
a1bbc6c0
SB
373
374 if (pack_everything & ALL_INTO_ONE) {
ed7e5fc3 375 get_non_kept_pack_filenames(&existing_packs, &keep_pack_list);
a1bbc6c0 376
5d19e813
JT
377 repack_promisor_objects(&po_args, &names);
378
a1bbc6c0 379 if (existing_packs.nr && delete_redundant) {
8d422993 380 if (unpack_unreachable) {
a2bae2dc 381 argv_array_pushf(&cmd.args,
a1bbc6c0
SB
382 "--unpack-unreachable=%s",
383 unpack_unreachable);
8d422993
JK
384 argv_array_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
385 } else if (pack_everything & LOOSEN_UNREACHABLE) {
a2bae2dc 386 argv_array_push(&cmd.args,
a1bbc6c0 387 "--unpack-unreachable");
905f27b8
JK
388 } else if (keep_unreachable) {
389 argv_array_push(&cmd.args, "--keep-unreachable");
e26a8c47 390 argv_array_push(&cmd.args, "--pack-loose-unreachable");
8d422993
JK
391 } else {
392 argv_array_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
393 }
a1bbc6c0
SB
394 }
395 } else {
a2bae2dc
RS
396 argv_array_push(&cmd.args, "--unpacked");
397 argv_array_push(&cmd.args, "--incremental");
a1bbc6c0
SB
398 }
399
a1bbc6c0
SB
400 cmd.no_stdin = 1;
401
402 ret = start_command(&cmd);
403 if (ret)
ffc9329f 404 return ret;
a1bbc6c0 405
a1bbc6c0 406 out = xfdopen(cmd.out, "r");
8f309aeb 407 while (strbuf_getline_lf(&line, out) != EOF) {
2f0c9e9a 408 if (line.len != the_hash_algo->hexsz)
3813a89f 409 die(_("repack: Expecting full hex object ID lines only from pack-objects."));
a1bbc6c0 410 string_list_append(&names, line.buf);
a1bbc6c0
SB
411 }
412 fclose(out);
413 ret = finish_command(&cmd);
414 if (ret)
ffc9329f 415 return ret;
a1bbc6c0 416
2b958e79 417 if (!names.nr && !po_args.quiet)
c83d950e 418 printf_ln(_("Nothing new to pack."));
a1bbc6c0 419
2d511cfc 420 close_object_store(the_repository->objects);
5bdece0d 421
a1bbc6c0
SB
422 /*
423 * Ok we have prepared all new packfiles.
424 * First see if there are packs of the same name and if so
425 * if we can move them out of the way (this can happen if we
426 * repacked immediately after packing fully.
427 */
428 failed = 0;
429 for_each_string_list_item(item, &names) {
b328c216 430 for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
e3cf2303 431 char *fname, *fname_old;
525e18c0
DS
432
433 if (!midx_cleared) {
1dcd9f20 434 clear_midx_file(the_repository);
525e18c0
DS
435 midx_cleared = 1;
436 }
437
9d7fbfd2 438 fname = mkpathdup("%s/pack-%s%s", packdir,
42a02d85 439 item->string, exts[ext].name);
a1bbc6c0
SB
440 if (!file_exists(fname)) {
441 free(fname);
442 continue;
443 }
444
e3cf2303 445 fname_old = mkpathdup("%s/old-%s%s", packdir,
42a02d85 446 item->string, exts[ext].name);
a1bbc6c0
SB
447 if (file_exists(fname_old))
448 if (unlink(fname_old))
449 failed = 1;
450
451 if (!failed && rename(fname, fname_old)) {
452 free(fname);
e3cf2303 453 free(fname_old);
a1bbc6c0
SB
454 failed = 1;
455 break;
456 } else {
457 string_list_append(&rollback, fname);
e3cf2303 458 free(fname_old);
a1bbc6c0
SB
459 }
460 }
461 if (failed)
462 break;
463 }
464 if (failed) {
465 struct string_list rollback_failure = STRING_LIST_INIT_DUP;
466 for_each_string_list_item(item, &rollback) {
e3cf2303 467 char *fname, *fname_old;
a1bbc6c0 468 fname = mkpathdup("%s/%s", packdir, item->string);
e3cf2303 469 fname_old = mkpathdup("%s/old-%s", packdir, item->string);
a1bbc6c0
SB
470 if (rename(fname_old, fname))
471 string_list_append(&rollback_failure, fname);
472 free(fname);
e3cf2303 473 free(fname_old);
a1bbc6c0
SB
474 }
475
476 if (rollback_failure.nr) {
477 int i;
478 fprintf(stderr,
c83d950e
NTND
479 _("WARNING: Some packs in use have been renamed by\n"
480 "WARNING: prefixing old- to their name, in order to\n"
481 "WARNING: replace them with the new version of the\n"
482 "WARNING: file. But the operation failed, and the\n"
483 "WARNING: attempt to rename them back to their\n"
484 "WARNING: original names also failed.\n"
485 "WARNING: Please rename them in %s manually:\n"), packdir);
a1bbc6c0
SB
486 for (i = 0; i < rollback_failure.nr; i++)
487 fprintf(stderr, "WARNING: old-%s -> %s\n",
488 rollback_failure.items[i].string,
489 rollback_failure.items[i].string);
490 }
491 exit(1);
492 }
493
494 /* Now the ones with the same name are out of the way... */
495 for_each_string_list_item(item, &names) {
b328c216 496 for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
a1bbc6c0
SB
497 char *fname, *fname_old;
498 struct stat statbuffer;
b77fcd1e 499 int exists = 0;
a1bbc6c0 500 fname = mkpathdup("%s/pack-%s%s",
42a02d85 501 packdir, item->string, exts[ext].name);
a1bbc6c0 502 fname_old = mkpathdup("%s-%s%s",
42a02d85 503 packtmp, item->string, exts[ext].name);
a1bbc6c0
SB
504 if (!stat(fname_old, &statbuffer)) {
505 statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
506 chmod(fname_old, statbuffer.st_mode);
b77fcd1e
JK
507 exists = 1;
508 }
509 if (exists || !exts[ext].optional) {
510 if (rename(fname_old, fname))
511 die_errno(_("renaming '%s' failed"), fname_old);
a1bbc6c0 512 }
a1bbc6c0
SB
513 free(fname);
514 free(fname_old);
515 }
516 }
517
518 /* Remove the "old-" files */
519 for_each_string_list_item(item, &names) {
b328c216 520 for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
e3cf2303
JK
521 char *fname;
522 fname = mkpathdup("%s/old-%s%s",
523 packdir,
524 item->string,
525 exts[ext].name);
0b63c6a5 526 if (remove_path(fname))
e923a8ab 527 warning(_("failed to remove '%s'"), fname);
e3cf2303 528 free(fname);
a1bbc6c0
SB
529 }
530 }
531
532 /* End of pack replacement. */
533
5d19e813
JT
534 reprepare_packed_git(the_repository);
535
a1bbc6c0 536 if (delete_redundant) {
2f0c9e9a 537 const int hexsz = the_hash_algo->hexsz;
4489a480 538 int opts = 0;
3383e199 539 string_list_sort(&names);
a1bbc6c0
SB
540 for_each_string_list_item(item, &existing_packs) {
541 char *sha1;
542 size_t len = strlen(item->string);
2f0c9e9a 543 if (len < hexsz)
a1bbc6c0 544 continue;
2f0c9e9a 545 sha1 = item->string + len - hexsz;
a1bbc6c0
SB
546 if (!string_list_has_string(&names, sha1))
547 remove_redundant_pack(packdir, item->string);
548 }
2b958e79 549 if (!po_args.quiet && isatty(2))
4489a480
RS
550 opts |= PRUNE_PACKED_VERBOSE;
551 prune_packed_objects(opts);
5dcfbf56
JS
552
553 if (!keep_unreachable &&
554 (!(pack_everything & LOOSEN_UNREACHABLE) ||
555 unpack_unreachable) &&
556 is_repository_shallow(the_repository))
557 prune_shallow(PRUNE_QUICK);
a1bbc6c0
SB
558 }
559
4489a480
RS
560 if (!no_update_server_info)
561 update_server_info(0);
a1bbc6c0 562 remove_temporary_files();
0465a505
DS
563
564 if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0))
565 write_midx_file(get_object_directory());
566
a1bbc6c0
SB
567 string_list_clear(&names, 0);
568 string_list_clear(&rollback, 0);
569 string_list_clear(&existing_packs, 0);
570 strbuf_release(&line);
571
572 return 0;
573}