diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-12-31 00:28:53 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-12-31 00:28:53 +0100 |
commit | 44bad3d98e9fe41fc103b6981ec3c623ef9388f3 (patch) | |
tree | 5f11f9998636b0927a975face16ca32e28374682 /org.eclipse.jgit | |
parent | f86d82fc30cd2cc11ca41947f82cc376f94e350d (diff) | |
parent | 8a4b98376785a6c271fede00035fe89dea2b9982 (diff) | |
download | jgit-44bad3d98e9fe41fc103b6981ec3c623ef9388f3.tar.gz jgit-44bad3d98e9fe41fc103b6981ec3c623ef9388f3.zip |
Merge branch 'stable-5.11' into stable-5.12
* stable-5.11:
Use FileSnapshot without using configs for FileBasedConfig
Change-Id: I4e241860c2ca50750e22c2761c515c9895688c55
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java | 25 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java | 2 |
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 78262e9773..d06b5a72d1 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 @@ -106,6 +106,8 @@ public class LockFile { private boolean written; + private boolean snapshotNoConfig; + private FileSnapshot commitSnapshot; private LockToken token; @@ -403,6 +405,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 @@ -480,8 +497,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 0b9b981088..7b5f00e4fe 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 @@ -219,7 +219,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())); |