Skip to content

Commit 0a0865b

Browse files
mhaggergitster
authored andcommitted
refs_ref_iterator_begin(): handle GIT_REF_PARANOIA
Instead of handling `GIT_REF_PARANOIA` in `files_ref_iterator_begin()`, handle it in `refs_ref_iterator_begin()`, where it will cover all reference stores. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 89c571d commit 0a0865b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

refs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,11 @@ struct ref_iterator *refs_ref_iterator_begin(
12591259
{
12601260
struct ref_iterator *iter;
12611261

1262+
if (ref_paranoia < 0)
1263+
ref_paranoia = git_env_bool("GIT_REF_PARANOIA", 0);
1264+
if (ref_paranoia)
1265+
flags |= DO_FOR_EACH_INCLUDE_BROKEN;
1266+
12621267
iter = refs->be->iterator_begin(refs, prefix, flags);
12631268

12641269
/*

refs/files-backend.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,15 +1074,12 @@ static struct ref_iterator *files_ref_iterator_begin(
10741074
struct ref_iterator *loose_iter, *packed_iter;
10751075
struct files_ref_iterator *iter;
10761076
struct ref_iterator *ref_iterator;
1077+
unsigned int required_flags = REF_STORE_READ;
10771078

1078-
if (ref_paranoia < 0)
1079-
ref_paranoia = git_env_bool("GIT_REF_PARANOIA", 0);
1080-
if (ref_paranoia)
1081-
flags |= DO_FOR_EACH_INCLUDE_BROKEN;
1079+
if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN))
1080+
required_flags |= REF_STORE_ODB;
10821081

1083-
refs = files_downcast(ref_store,
1084-
REF_STORE_READ | (ref_paranoia ? 0 : REF_STORE_ODB),
1085-
"ref_iterator_begin");
1082+
refs = files_downcast(ref_store, required_flags, "ref_iterator_begin");
10861083

10871084
iter = xcalloc(1, sizeof(*iter));
10881085
ref_iterator = &iter->base;

0 commit comments

Comments
 (0)