From a1d7d4378266076bd7d61f835f31ad929c6358b5 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Tue, 28 Jan 2014 01:09:54 -0500 Subject: repack: add `repack.honorpackkeep` config var The git-repack command always passes `--honor-pack-keep` to pack-objects. This has traditionally been a good thing, as we do not want to duplicate those objects in a new pack, and we are not going to delete the old pack. However, when bitmaps are in use, it is important for a full repack to include all reachable objects, even if they may be duplicated in a .keep pack. Otherwise, we cannot generate the bitmaps, as the on-disk format requires the set of objects in the pack to be fully closed. Even if the repository does not generally have .keep files, a simultaneous push could cause a race condition in which a .keep file exists at the moment of a repack. The repack may try to include those objects in one of two situations: 1. The pushed .keep pack contains objects that were already in the repository (e.g., blobs due to a revert of an old commit). 2. Receive-pack updates the refs, making the objects reachable, but before it removes the .keep file, the repack runs. In either case, we may prefer to duplicate some objects in the new, full pack, and let the next repack (after the .keep file is cleaned up) take care of removing them. This patch introduces an option to disable the `--honor-pack-keep` option. It is not triggered by default, even when pack.writeBitmaps is turned on, because its use depends on your overall packing strategy and use of .keep files. Note that this option just disables the pack-objects behavior. We still leave packs with a .keep in place, as we do not necessarily know that we have duplicated all of their objects. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- Documentation/config.txt | 8 ++++++++ builtin/repack.c | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 499a3c4360..ed98e91ed8 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -2128,6 +2128,14 @@ repack.usedeltabaseoffset:: "false" and repack. Access from old Git versions over the native protocol are unaffected by this option. +repack.honorPackKeep:: + If set to false, include objects in `.keep` files when repacking + via `git repack`. Note that we still do not delete `.keep` packs + after `pack-objects` finishes. This means that we may duplicate + objects, but this makes the option safe to use when there are + concurrent pushes or fetches. This option is generally only + useful if you have set `pack.writeBitmaps`. Defaults to true. + rerere.autoupdate:: When set to true, `git-rerere` updates the index with the resulting contents after it cleanly resolves conflicts using diff --git a/builtin/repack.c b/builtin/repack.c index 239f278fac..b4439edf26 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -9,6 +9,7 @@ #include "argv-array.h" static int delta_base_offset = 1; +static int honor_pack_keep = 1; static char *packdir, *packtmp; static const char *const git_repack_usage[] = { @@ -22,6 +23,10 @@ static int repack_config(const char *var, const char *value, void *cb) delta_base_offset = git_config_bool(var, value); return 0; } + if (!strcmp(var, "repack.honorpackkeep")) { + honor_pack_keep = git_config_bool(var, value); + return 0; + } return git_default_config(var, value, cb); } @@ -190,10 +195,11 @@ int cmd_repack(int argc, const char **argv, const char *prefix) argv_array_push(&cmd_args, "pack-objects"); argv_array_push(&cmd_args, "--keep-true-parents"); - argv_array_push(&cmd_args, "--honor-pack-keep"); argv_array_push(&cmd_args, "--non-empty"); argv_array_push(&cmd_args, "--all"); argv_array_push(&cmd_args, "--reflog"); + if (honor_pack_keep) + argv_array_push(&cmd_args, "--honor-pack-keep"); if (window) argv_array_pushf(&cmd_args, "--window=%u", window); if (window_memory) -- cgit v1.2.1