Skip to content

Commit 5d1f5b8

Browse files
peffgitster
authored andcommitted
repack, prune: drop GIT_REF_PARANOIA settings
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 <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 968f12f commit 5d1f5b8

File tree

5 files changed

+2
-13
lines changed

5 files changed

+2
-13
lines changed

builtin/prune.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
143143
expire = TIME_MAX;
144144
save_commit_buffer = 0;
145145
read_replace_refs = 0;
146-
ref_paranoia = 1;
147146
repo_init_revisions(the_repository, &revs, prefix);
148147

149148
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);

builtin/repack.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,12 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
586586
strvec_pushf(&cmd.args,
587587
"--unpack-unreachable=%s",
588588
unpack_unreachable);
589-
strvec_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
590589
} else if (pack_everything & LOOSEN_UNREACHABLE) {
591590
strvec_push(&cmd.args,
592591
"--unpack-unreachable");
593592
} else if (keep_unreachable) {
594593
strvec_push(&cmd.args, "--keep-unreachable");
595594
strvec_push(&cmd.args, "--pack-loose-unreachable");
596-
} else {
597-
strvec_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
598595
}
599596
}
600597
} else if (geometry) {

cache.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -994,14 +994,6 @@ extern const char *core_fsmonitor;
994994
extern int core_apply_sparse_checkout;
995995
extern int core_sparse_checkout_cone;
996996

997-
/*
998-
* Include broken refs in all ref iterations, which will
999-
* generally choke dangerous operations rather than letting
1000-
* them silently proceed without taking the broken ref into
1001-
* account.
1002-
*/
1003-
extern int ref_paranoia;
1004-
1005997
/*
1006998
* Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
1007999
*/

environment.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ int prefer_symlink_refs;
3131
int is_bare_repository_cfg = -1; /* unspecified */
3232
int warn_ambiguous_refs = 1;
3333
int warn_on_object_refname_ambiguity = 1;
34-
int ref_paranoia = -1;
3534
int repository_format_precious_objects;
3635
int repository_format_worktree_config;
3736
const char *git_commit_encoding;

refs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,8 @@ struct ref_iterator *refs_ref_iterator_begin(
14191419
struct ref_iterator *iter;
14201420

14211421
if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
1422+
static int ref_paranoia = -1;
1423+
14221424
if (ref_paranoia < 0)
14231425
ref_paranoia = git_env_bool("GIT_REF_PARANOIA", 1);
14241426
if (ref_paranoia) {

0 commit comments

Comments
 (0)