git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Siddharth Agarwal <sid0@fb.com>
Cc: Vicent Marti <tanoku@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org
Subject: [PATCH] repack: add `repack.honorpackkeep` config var
Date: Tue, 28 Jan 2014 01:09:54 -0500	[thread overview]
Message-ID: <20140128060954.GA26401@sigill.intra.peff.net> (raw)
In-Reply-To: <52E1D39B.4050103@fb.com>

On Thu, Jan 23, 2014 at 06:44:43PM -0800, Siddharth Agarwal wrote:

> On 01/23/2014 06:28 PM, Jeff King wrote:
> >I think your understanding is accurate here. So we want repack to
> >respect keep files for deletion, but we _not_ necessarily want
> >pack-objects to avoid packing an object just because it's in a pack
> >marked by .keep (see my other email).
> 
> Yes, that makes sense and sounds pretty safe.
> 
> So the right solution for us probably is to apply the patch Vicent
> posted, set repack.honorpackkeep to false, and also have a cron job
> that cleans up stale .keep files so that subsequent repacks clean it
> up.

Yes, that matches what we do at GitHub.

Here's Vicent's patch, with documentation and an expanded commit
message. I think it should be suitable for upstream git.

-- >8 --
From: Vicent Marti <tanoku@gmail.com>
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 <peff@peff.net>
---
Intended for the jk/pack-bitmap topic.

 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 947e6f8..5036a10 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 a9c4593..585c41d 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)
-- 
1.8.5.2.500.g8060133

  reply	other threads:[~2014-01-28  6:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23  2:38 WIth git-next, writing bitmaps fails when keep files are present Siddharth Agarwal
2014-01-23 20:36 ` Siddharth Agarwal
2014-01-23 22:52 ` [PATCH] pack-objects: turn off bitmaps when skipping objects Jeff King
2014-01-23 23:45   ` Siddharth Agarwal
2014-01-23 23:53     ` Siddharth Agarwal
2014-01-24  2:28       ` Jeff King
2014-01-24  2:44         ` Siddharth Agarwal
2014-01-28  6:09           ` Jeff King [this message]
2014-01-28  9:21             ` [PATCH] repack: add `repack.honorpackkeep` config var Junio C Hamano
2014-02-24  8:24               ` Jeff King
2014-02-24 19:10                 ` Junio C Hamano
2014-02-26 10:13                   ` Jeff King
2014-02-26 20:30                     ` Junio C Hamano
2014-02-27 11:27                       ` Jeff King
2014-02-27 18:04                         ` Junio C Hamano
2014-02-28  8:55                           ` Jeff King
2014-02-28 17:09                             ` Nasser Grainawi
2014-03-01  6:05                               ` Jeff King
2014-03-03 19:12                                 ` Shawn Pearce
2014-02-28 18:45                             ` Junio C Hamano
2014-03-01  5:43                               ` Jeff King
2014-03-03 18:13                                 ` Junio C Hamano
2014-03-03 18:15                                   ` Jeff King
2014-03-03 19:51                                     ` Junio C Hamano
2014-03-03 20:04                                       ` Jeff King
2014-01-23 23:56     ` [PATCH] pack-objects: turn off bitmaps when skipping objects Vicent Martí
2014-01-24  2:26       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140128060954.GA26401@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sid0@fb.com \
    --cc=tanoku@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).