diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-12-30 23:33:06 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-12-30 23:33:06 +0100 |
commit | 62c2159b6280939fbc1fd195c79a73c1766410dc (patch) | |
tree | 3ba65a0f2b60bc03a2752e8a27fa4ee161550fa6 /org.eclipse.jgit/src/org | |
parent | 7edb062d8c3d6375c25463d43b5b0ade8a7778ee (diff) | |
parent | f33ae743ade6dbd7a4279233816a2426c008e8ad (diff) | |
download | jgit-62c2159b6280939fbc1fd195c79a73c1766410dc.tar.gz jgit-62c2159b6280939fbc1fd195c79a73c1766410dc.zip |
Merge branch 'stable-5.2' into stable-5.3stable-5.3
* stable-5.2:
Use FileSnapshot without using configs for FileBasedConfig
Change-Id: Ib79c310c5b632e845ba69ce65e739ae0146103ca
Diffstat (limited to 'org.eclipse.jgit/src/org')
-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 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())); |