diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-12-30 23:41:54 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-12-30 23:41:54 +0100 |
commit | d87e5e07a542ff40b3fb3e3ca02c170a127b9e2a (patch) | |
tree | 4b128264cf2a0d0daeeb065b7e1e2614dc3526a5 /org.eclipse.jgit/src/org | |
parent | fd612a12821910f7fbfca88e2f9b0b955e2845f0 (diff) | |
parent | 7f51f8acd8a0e09cef2d96ff2eabbb2da8ea5176 (diff) | |
download | jgit-d87e5e07a542ff40b3fb3e3ca02c170a127b9e2a.tar.gz jgit-d87e5e07a542ff40b3fb3e3ca02c170a127b9e2a.zip |
Merge branch 'stable-5.4' into stable-5.5stable-5.5
* stable-5.4:
Use FileSnapshot without using configs for FileBasedConfig
Change-Id: I84e11bdaa9306e23212dac9d8670557a18d40107
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 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())); |