Skip to content

Commit

Permalink
repack: turn on "ref paranoia" when doing a destructive repack
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 20, 2015
1 parent ff4056b commit 8d42299
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions builtin/repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion t/t5312-prune-corruption.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 8d42299

Please sign in to comment.