]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'tb/repack-expire-to'
authorTaylor Blau <me@ttaylorr.com>
Fri, 18 Nov 2022 23:43:09 +0000 (18:43 -0500)
committerTaylor Blau <me@ttaylorr.com>
Fri, 18 Nov 2022 23:43:09 +0000 (18:43 -0500)
"git repack" learns to send cruft objects out of the way into
packfiles outside the repository.

* tb/repack-expire-to:
  builtin/repack.c: implement `--expire-to` for storing pruned objects
  builtin/repack.c: write cruft packs to arbitrary locations
  builtin/repack.c: pass "cruft_expiration" to `write_cruft_pack`
  builtin/repack.c: pass "out" to `prepare_pack_objects`

1  2 
builtin/repack.c
t/t7700-repack.sh

index 10e23f9ee1fc4baea34152c23ea8ab5459986ae5,a70962ee038b2c4c40aec3fd474089451152c5bb..65eb1b8bd22b4119908abe700cfd3a6d143289f1
@@@ -627,37 -661,10 +627,39 @@@ static int write_midx_included_packs(st
        return finish_command(&cmd);
  }
  
 +static void remove_redundant_bitmaps(struct string_list *include,
 +                                   const char *packdir)
 +{
 +      struct strbuf path = STRBUF_INIT;
 +      struct string_list_item *item;
 +      size_t packdir_len;
 +
 +      strbuf_addstr(&path, packdir);
 +      strbuf_addch(&path, '/');
 +      packdir_len = path.len;
 +
 +      /*
 +       * Remove any pack bitmaps corresponding to packs which are now
 +       * included in the MIDX.
 +       */
 +      for_each_string_list_item(item, include) {
 +              strbuf_addstr(&path, item->string);
 +              strbuf_strip_suffix(&path, ".idx");
 +              strbuf_addstr(&path, ".bitmap");
 +
 +              if (unlink(path.buf) && errno != ENOENT)
 +                      warning_errno(_("could not remove stale bitmap: %s"),
 +                                    path.buf);
 +
 +              strbuf_setlen(&path, packdir_len);
 +      }
 +      strbuf_release(&path);
 +}
 +
  static int write_cruft_pack(const struct pack_objects_args *args,
+                           const char *destination,
                            const char *pack_prefix,
+                           const char *cruft_expiration,
                            struct string_list *names,
                            struct string_list *existing_packs,
                            struct string_list *existing_kept_packs)
                if (line.len != the_hash_algo->hexsz)
                        die(_("repack: Expecting full hex object ID lines only "
                              "from pack-objects."));
-               item = string_list_append(names, line.buf);
-               item->util = populate_pack_exts(line.buf);
+               /*
+                * avoid putting packs written outside of the repository in the
+                * list of names
+                */
 -              if (local)
 -                      string_list_append(names, line.buf);
++              if (local) {
++                      item = string_list_append(names, line.buf);
++                      item->util = populate_pack_exts(line.buf);
++              }
        }
        fclose(out);
  
@@@ -858,7 -876,9 +875,7 @@@ int cmd_repack(int argc, const char **a
                split_pack_geometry(geometry, geometric_factor);
        }
  
-       prepare_pack_objects(&cmd, &po_args);
 -      sigchain_push_common(remove_pack_on_signal);
 -
+       prepare_pack_objects(&cmd, &po_args, packtmp);
  
        show_progress = !po_args.quiet && isatty(2);
  
Simple merge