aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-12-30 23:18:21 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2021-12-30 23:18:21 +0100
commitf33ae743ade6dbd7a4279233816a2426c008e8ad (patch)
treef16d44495cd84d7acd3c4fe4611cddf7d5edb3fb /org.eclipse.jgit/src/org
parentf2d4783c5256b8ad925aa548c70d53d0ec1d88ce (diff)
parentfed0ab9baad30a58bfae30ce8b45e5ba3b1b1a10 (diff)
downloadjgit-f33ae743ade6dbd7a4279233816a2426c008e8ad.tar.gz
jgit-f33ae743ade6dbd7a4279233816a2426c008e8ad.zip
Merge branch 'stable-5.1' into stable-5.2stable-5.2
* stable-5.1: Use FileSnapshot without using configs for FileBasedConfig Change-Id: I17ede8876a0cf231c38cb9652c7bf51553b1e90e
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java25
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java2
2 files changed, 24 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
index f7e78b94f7..548ea5af55 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
@@ -137,6 +137,8 @@ public class LockFile {
private boolean needSnapshot;
+ private boolean snapshotNoConfig;
+
boolean fsync;
private FileSnapshot commitSnapshot;
@@ -407,6 +409,21 @@ public class LockFile {
}
/**
+ * Request that {@link #commit()} remember the
+ * {@link org.eclipse.jgit.internal.storage.file.FileSnapshot} without using
+ * config file to get filesystem timestamp resolution.
+ * This method should be invoked before the file is accessed.
+ * It is used by FileBasedConfig to avoid endless recursion.
+ *
+ * @param on
+ * true if the commit method must remember the FileSnapshot.
+ */
+ public void setNeedSnapshotNoConfig(boolean on) {
+ needSnapshot = on;
+ snapshotNoConfig = on;
+ }
+
+ /**
* Request that {@link #commit()} force dirty data to the drive.
*
* @param on
@@ -482,8 +499,12 @@ public class LockFile {
}
private void saveStatInformation() {
- if (needSnapshot)
- commitSnapshot = FileSnapshot.save(lck);
+ if (needSnapshot) {
+ commitSnapshot = snapshotNoConfig ?
+ // don't use config in this snapshot to avoid endless recursion
+ FileSnapshot.saveNoConfig(lck)
+ : FileSnapshot.save(lck);
+ }
}
/**
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 bdbd7c9072..072938b482 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
@@ -235,7 +235,7 @@ public class FileBasedConfig extends StoredConfig {
if (!lf.lock())
throw new LockFailedException(getFile());
try {
- lf.setNeedSnapshot(true);
+ lf.setNeedSnapshotNoConfig(true);
lf.write(out);
if (!lf.commit())
throw new IOException(MessageFormat.format(JGitText.get().cannotCommitWriteTo, getFile()));