private static final PackList NO_PACKS = new PackList(FileSnapshot.DIRTY,
new Pack[0]);
- private final Config config;
-
private final File directory;
private final AtomicReference<PackList> packList;
+ private final boolean trustFolderStat;
+
/**
* Initialize a reference to an on-disk 'pack' directory.
*
* the location of the {@code pack} directory.
*/
PackDirectory(Config config, File directory) {
- this.config = config;
this.directory = directory;
packList = new AtomicReference<>(NO_PACKS);
+
+ // Whether to trust the pack folder's modification time. If set to false
+ // we will always scan the .git/objects/pack folder to check for new
+ // pack files. If set to true (default) we use the folder's size,
+ // modification time, and key (inode) and assume that no new pack files
+ // can be in this folder if these attributes have not changed.
+ trustFolderStat = config.getBoolean(ConfigConstants.CONFIG_CORE_SECTION,
+ ConfigConstants.CONFIG_KEY_TRUSTFOLDERSTAT, true);
}
/**
}
boolean searchPacksAgain(PackList old) {
- // Whether to trust the pack folder's modification time. If set
- // to false we will always scan the .git/objects/pack folder to
- // check for new pack files. If set to true (default) we use the
- // lastmodified attribute of the folder and assume that no new
- // pack files can be in this folder if his modification time has
- // not changed.
- boolean trustFolderStat = config.getBoolean(
- ConfigConstants.CONFIG_CORE_SECTION,
- ConfigConstants.CONFIG_KEY_TRUSTFOLDERSTAT, true);
-
return ((!trustFolderStat) || old.snapshot.isModified(directory))
&& old != scanPacks(old);
}
private List<Integer> retrySleepMs = RETRY_SLEEP_MS;
+ private final boolean trustFolderStat;
+
+ private final TrustPackedRefsStat trustPackedRefsStat;
+
RefDirectory(FileRepository db) {
final FS fs = db.getFS();
parent = db;
looseRefs.set(RefList.<LooseRef> emptyList());
packedRefs.set(NO_PACKED_REFS);
+ trustFolderStat = db.getConfig()
+ .getBoolean(ConfigConstants.CONFIG_CORE_SECTION,
+ ConfigConstants.CONFIG_KEY_TRUSTFOLDERSTAT, true);
+ trustPackedRefsStat = db.getConfig()
+ .getEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_TRUST_PACKED_REFS_STAT,
+ TrustPackedRefsStat.UNSET);
}
Repository getRepository() {
}
PackedRefList getPackedRefs() throws IOException {
- boolean trustFolderStat = getRepository().getConfig().getBoolean(
- ConfigConstants.CONFIG_CORE_SECTION,
- ConfigConstants.CONFIG_KEY_TRUSTFOLDERSTAT, true);
- TrustPackedRefsStat trustPackedRefsStat =
- getRepository().getConfig().getEnum(
- ConfigConstants.CONFIG_CORE_SECTION,
- null,
- ConfigConstants.CONFIG_KEY_TRUST_PACKED_REFS_STAT,
- TrustPackedRefsStat.UNSET);
-
final PackedRefList curList = packedRefs.get();
switch (trustPackedRefsStat) {