diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-12-30 23:40:21 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-12-30 23:40:21 +0100 |
commit | 7f51f8acd8a0e09cef2d96ff2eabbb2da8ea5176 (patch) | |
tree | 69e711dd8130c93f4787c9a631eb35e594dc0fc7 /org.eclipse.jgit/src/org/eclipse | |
parent | 4cc21ccd3d1cd2374c4af3e164b8daef81be4505 (diff) | |
parent | 62c2159b6280939fbc1fd195c79a73c1766410dc (diff) | |
download | jgit-7f51f8acd8a0e09cef2d96ff2eabbb2da8ea5176.tar.gz jgit-7f51f8acd8a0e09cef2d96ff2eabbb2da8ea5176.zip |
Merge branch 'stable-5.3' into stable-5.4stable-5.4
* stable-5.3:
Use FileSnapshot without using configs for FileBasedConfig
Change-Id: I3d8eb2fa721e1a791db47a2342acc690ced01715
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-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 6af41256d6..eda4da8e90 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 @@ -133,6 +133,8 @@ public class LockFile { private boolean needSnapshot; + private boolean snapshotNoConfig; + boolean fsync; private FileSnapshot commitSnapshot; @@ -385,6 +387,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 @@ -460,8 +477,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 5bb8153a58..9bec2e177d 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 @@ -252,7 +252,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())); |