repack: turn on "ref paranoia" when doing a destructive repack
[gitweb.git] / builtin / repack.c
index 3f852f35d1e786b2584d435d640ae830a9f34639..2fe1b30d716958b451a5486dcedfb811062f786f 100644 (file)
@@ -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");