summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf <twolf@apache.org>2023-10-08 21:53:06 +0200
committerThomas Wolf <twolf@apache.org>2023-10-14 23:33:11 +0200
commitcb46ee3544536525446317a98b5cb02377f0cfa5 (patch)
treec6d16485114d299eeaed0fc5dfab2a610615b25a
parent621685d3ca5fbaba37a8fc79b347644b3e4425c0 (diff)
downloadjgit-cb46ee3544536525446317a98b5cb02377f0cfa5.tar.gz
jgit-cb46ee3544536525446317a98b5cb02377f0cfa5.zip
FileBasedConfig: ensure correct snapshot if no file
When no config file exists, use FileSnapshot.MISSING_FILE. Bug: 451508 Change-Id: I8a09cb756a8a4746189da5b3514dfcf81d10b3b1 Signed-off-by: Thomas Wolf <twolf@apache.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java4
1 files changed, 1 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java
index cedc4d6cc9..c80505d709 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java
@@ -117,13 +117,11 @@ public class FileBasedConfig extends StoredConfig {
@Override
public void load() throws IOException, ConfigInvalidException {
try {
- FileSnapshot[] lastSnapshot = { null };
Boolean wasRead = FileUtils.readWithRetries(getFile(), f -> {
final FileSnapshot oldSnapshot = snapshot;
final FileSnapshot newSnapshot;
// don't use config in this snapshot to avoid endless recursion
newSnapshot = FileSnapshot.saveNoConfig(f);
- lastSnapshot[0] = newSnapshot;
final byte[] in = IO.readFully(f);
final ObjectId newHash = hash(in);
if (hash.equals(newHash)) {
@@ -149,7 +147,7 @@ public class FileBasedConfig extends StoredConfig {
});
if (wasRead == null) {
clear();
- snapshot = lastSnapshot[0];
+ snapshot = FileSnapshot.MISSING_FILE;
}
exists.set(wasRead != null);
} catch (IOException e) {