]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repack, prune: drop GIT_REF_PARANOIA settings
authorJeff King <peff@peff.net>
Fri, 24 Sep 2021 18:46:37 +0000 (14:46 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Sep 2021 19:36:45 +0000 (12:36 -0700)
Now that GIT_REF_PARANOIA is the default, we don't need to selectively
enable it for destructive operations. In fact, it's harmful to do so,
because it overrides any GIT_REF_PARANOIA=0 setting that the user may
have provided (because they're trying to work around some corruption).

With these uses gone, we can further clean up the ref_paranoia global,
and make it a static variable inside the refs code.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/prune.c
builtin/repack.c
cache.h
environment.c
refs.c

index 02c6ab7cbaafbac6492fd458bedc0f162e81d683..485c9a3c56ff96aa59d9d9b4bfec1ea894ac32dd 100644 (file)
@@ -143,7 +143,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
        expire = TIME_MAX;
        save_commit_buffer = 0;
        read_replace_refs = 0;
-       ref_paranoia = 1;
        repo_init_revisions(the_repository, &revs, prefix);
 
        argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
index c1a209013b3a9747dfee23d42fd2430e5372fbc3..cb9f4bfed33cdcfd3ca3d6d5490248387977ba82 100644 (file)
@@ -586,15 +586,12 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                                strvec_pushf(&cmd.args,
                                             "--unpack-unreachable=%s",
                                             unpack_unreachable);
-                               strvec_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
                        } else if (pack_everything & LOOSEN_UNREACHABLE) {
                                strvec_push(&cmd.args,
                                            "--unpack-unreachable");
                        } else if (keep_unreachable) {
                                strvec_push(&cmd.args, "--keep-unreachable");
                                strvec_push(&cmd.args, "--pack-loose-unreachable");
-                       } else {
-                               strvec_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
                        }
                }
        } else if (geometry) {
diff --git a/cache.h b/cache.h
index f6295f3b048ad0e6446d7fab487b59cf27598edb..f445008895387794c3b47a3b00affa2f94721aa9 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -994,14 +994,6 @@ extern const char *core_fsmonitor;
 extern int core_apply_sparse_checkout;
 extern int core_sparse_checkout_cone;
 
-/*
- * Include broken refs in all ref iterations, which will
- * generally choke dangerous operations rather than letting
- * them silently proceed without taking the broken ref into
- * account.
- */
-extern int ref_paranoia;
-
 /*
  * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
  */
index b4ba4fa22dbe41f3651fe8c39c3d5b108775e470..7923ab21dda60edcd96136a90765195ad7983067 100644 (file)
@@ -31,7 +31,6 @@ int prefer_symlink_refs;
 int is_bare_repository_cfg = -1; /* unspecified */
 int warn_ambiguous_refs = 1;
 int warn_on_object_refname_ambiguity = 1;
-int ref_paranoia = -1;
 int repository_format_precious_objects;
 int repository_format_worktree_config;
 const char *git_commit_encoding;
diff --git a/refs.c b/refs.c
index ac19c689fafc3ee50689306ebd7d0e11a98740f7..d0f4e8726badec8e39480cc01d5ed751ca20f5f9 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1419,6 +1419,8 @@ struct ref_iterator *refs_ref_iterator_begin(
        struct ref_iterator *iter;
 
        if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
+               static int ref_paranoia = -1;
+
                if (ref_paranoia < 0)
                        ref_paranoia = git_env_bool("GIT_REF_PARANOIA", 1);
                if (ref_paranoia) {