*/
@Override
public void load() throws IOException, ConfigInvalidException {
- load(true);
- }
-
- /**
- * Load the configuration as a Git text style configuration file.
- * <p>
- * If the file does not exist, this configuration is cleared, and thus
- * behaves the same as though the file exists, but is empty.
- *
- * @param useFileSnapshotWithConfig
- * if {@code true} use the FileSnapshot with config, otherwise
- * use it without config
- * @throws IOException
- * if IO failed
- * @throws ConfigInvalidException
- * if config is invalid
- * @since 5.1.9
- */
- public void load(boolean useFileSnapshotWithConfig)
- throws IOException, ConfigInvalidException {
final int maxStaleRetries = 5;
int retries = 0;
while (true) {
final FileSnapshot oldSnapshot = snapshot;
final FileSnapshot newSnapshot;
- if (useFileSnapshotWithConfig) {
- newSnapshot = FileSnapshot.save(getFile());
- } else {
- // don't use config in this snapshot to avoid endless recursion
- newSnapshot = FileSnapshot.saveNoConfig(getFile());
- }
+ // don't use config in this snapshot to avoid endless recursion
+ newSnapshot = FileSnapshot.saveNoConfig(getFile());
try {
final byte[] in = IO.readFully(getFile());
final ObjectId newHash = hash(in);
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.storage.file.FileBasedConfig;
+import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.treewalk.FileTreeIterator.FileEntry;
import org.eclipse.jgit.treewalk.FileTreeIterator.FileModeStrategy;
import org.eclipse.jgit.treewalk.WorkingTreeIterator.Entry;
private static Optional<FileStoreAttributes> readFromConfig(
FileStore s) {
- FileBasedConfig userConfig = SystemReader.getInstance()
+ StoredConfig userConfig = SystemReader.getInstance()
.openUserConfig(null, FS.DETECTED);
try {
- userConfig.load(false);
+ userConfig.load();
} catch (IOException e) {
LOG.error(MessageFormat.format(JGitText.get().readConfigFailed,
- userConfig.getFile().getAbsolutePath()), e);
+ userConfig), e);
} catch (ConfigInvalidException e) {
LOG.error(MessageFormat.format(
JGitText.get().repositoryConfigFileInvalid,
- userConfig.getFile().getAbsolutePath(),
+ userConfig,
e.getMessage()));
}
String key = getConfigKey(s);
private static void saveToConfig(FileStore s,
FileStoreAttributes c) {
- FileBasedConfig userConfig = SystemReader.getInstance()
+ StoredConfig userConfig = SystemReader.getInstance()
.openUserConfig(null, FS.DETECTED);
long resolution = c.getFsTimestampResolution().toNanos();
TimeUnit resolutionUnit = getUnit(resolution);
String key = getConfigKey(s);
while (!succeeded && retries < max_retries) {
try {
- userConfig.load(false);
+ userConfig.load();
userConfig.setString(
ConfigConstants.CONFIG_FILESYSTEM_SECTION, key,
ConfigConstants.CONFIG_KEY_TIMESTAMP_RESOLUTION,
// race with another thread, wait a bit and try again
try {
LOG.warn(MessageFormat.format(JGitText.get().cannotLock,
- userConfig.getFile().getAbsolutePath()));
+ userConfig));
retries++;
Thread.sleep(20);
} catch (InterruptedException e1) {
}
} catch (IOException e) {
LOG.error(MessageFormat.format(
- JGitText.get().cannotSaveConfig,
- userConfig.getFile().getAbsolutePath()), e);
+ JGitText.get().cannotSaveConfig, userConfig), e);
} catch (ConfigInvalidException e) {
LOG.error(MessageFormat.format(
JGitText.get().repositoryConfigFileInvalid,
- userConfig.getFile().getAbsolutePath(),
- e.getMessage()));
+ userConfig, e.getMessage()));
}
}
}