From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Michael Haggerty <mhagger@alum.mit.edu>
Subject: [PATCH 4/5] repack: turn on "ref paranoia" when doing a destructive repack
Date: Tue, 17 Mar 2015 03:31:02 -0400 [thread overview]
Message-ID: <20150317073102.GD25191@peff.net> (raw)
In-Reply-To: <20150317072750.GA22155@peff.net>
If we are repacking with "-ad", we will drop any unreachable
objects. Likewise, using "-Ad --unpack-unreachable=<time>"
will drop any old, unreachable objects. In these cases, we
want to make sure the reachability we compute with "--all"
is complete. We can do this by passing GIT_REF_PARANOIA=1 in
the environment to pack-objects.
Note that "-Ad" is safe already, because it only loosens
unreachable objects. It is up to "git prune" to avoid
deleting them.
Signed-off-by: Jeff King <peff@peff.net>
---
builtin/repack.c | 8 ++++++--
t/t5312-prune-corruption.sh | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index 28fbc70..f2edeb0 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -228,13 +228,17 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
get_non_kept_pack_filenames(&existing_packs);
if (existing_packs.nr && delete_redundant) {
- if (unpack_unreachable)
+ if (unpack_unreachable) {
argv_array_pushf(&cmd.args,
"--unpack-unreachable=%s",
unpack_unreachable);
- else if (pack_everything & LOOSEN_UNREACHABLE)
+ argv_array_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
+ } else if (pack_everything & LOOSEN_UNREACHABLE) {
argv_array_push(&cmd.args,
"--unpack-unreachable");
+ } else {
+ argv_array_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
+ }
}
} else {
argv_array_push(&cmd.args, "--unpacked");
diff --git a/t/t5312-prune-corruption.sh b/t/t5312-prune-corruption.sh
index cccab58..e3e9994 100755
--- a/t/t5312-prune-corruption.sh
+++ b/t/t5312-prune-corruption.sh
@@ -38,7 +38,7 @@ test_expect_success 'put bogus object into pack' '
verbose git cat-file -e $bogus
'
-test_expect_failure 'destructive repack keeps packed object' '
+test_expect_success 'destructive repack keeps packed object' '
test_might_fail git repack -Ad --unpack-unreachable=now &&
verbose git cat-file -e $bogus &&
test_might_fail git repack -ad &&
--
2.3.3.520.g3cfbb5d
next prev parent reply other threads:[~2015-03-17 7:31 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 7:27 [PATCH 0/5] not making corruption worse Jeff King
2015-03-17 7:28 ` [PATCH 1/5] t5312: test object deletion code paths in a corrupted repository Jeff King
2015-03-17 18:34 ` Johannes Sixt
2015-03-17 18:55 ` Jeff King
2015-03-18 20:42 ` Johannes Sixt
2015-03-19 20:04 ` Junio C Hamano
2015-03-19 20:51 ` Jeff King
2015-03-19 21:23 ` Junio C Hamano
2015-03-19 21:47 ` Jeff King
2015-03-19 21:49 ` Junio C Hamano
2015-03-19 21:52 ` Jeff King
2015-03-20 1:16 ` Eric Sunshine
2015-03-20 1:32 ` Jeff King
2015-03-20 1:37 ` Eric Sunshine
2015-03-20 2:08 ` test &&-chain lint (was: [PATCH 1/5] t5312: test object deletion code paths in a corrupted repository) Jeff King
2015-03-20 2:25 ` Jeff King
2015-03-20 5:10 ` Jeff King
2015-03-20 7:18 ` Eric Sunshine
2015-03-20 6:51 ` test &&-chain lint Junio C Hamano
2015-03-20 17:04 ` Junio C Hamano
2015-03-20 17:24 ` Jeff King
2015-03-20 17:34 ` Junio C Hamano
2015-03-20 17:59 ` Jeff King
2015-03-17 7:29 ` [PATCH 2/5] refs: introduce a "ref paranoia" flag Jeff King
2015-03-19 20:13 ` Junio C Hamano
2015-03-19 21:00 ` Jeff King
2015-03-19 21:31 ` Junio C Hamano
2015-03-19 21:51 ` Jeff King
2015-03-17 7:30 ` [PATCH 3/5] prune: turn on ref_paranoia flag Jeff King
2015-03-17 7:31 ` Jeff King [this message]
2015-03-17 7:31 ` [PATCH 5/5] refs.c: drop curate_packed_refs Jeff King
2015-03-20 1:27 ` Eric Sunshine
2015-03-17 7:37 ` [PATCH 0/5] not making corruption worse Jeff King
2015-03-17 22:54 ` Junio C Hamano
2015-03-18 10:21 ` Jeff King
2015-03-20 18:42 ` [PATCH v2 " Jeff King
2015-03-20 18:43 ` [PATCH v2 1/5] t5312: test object deletion code paths in a corrupted repository Jeff King
2015-03-20 18:43 ` [PATCH v2 2/5] refs: introduce a "ref paranoia" flag Jeff King
2015-03-20 18:43 ` [PATCH v2 3/5] prune: turn on ref_paranoia flag Jeff King
2015-03-20 18:43 ` [PATCH v2 4/5] repack: turn on "ref paranoia" when doing a destructive repack Jeff King
2015-03-20 18:43 ` [PATCH v2 5/5] refs.c: drop curate_packed_refs 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=20150317073102.GD25191@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=mhagger@alum.mit.edu \
/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).