diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-12-13 14:18:05 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-12-15 15:14:05 -0800 |
commit | 013cb8de3824c304645a9c5db87c2e80286872d1 (patch) | |
tree | d620e6700503a34b6da2359d238cbd2fda914ce9 /org.eclipse.jgit.test | |
parent | 86847ee3224ac93da478bc5cdb8a79140ee6edac (diff) | |
download | jgit-013cb8de3824c304645a9c5db87c2e80286872d1.tar.gz jgit-013cb8de3824c304645a9c5db87c2e80286872d1.zip |
Reduce calls to Repository.getConfig
Each time getConfig() is called on FileRepository, it checks the
last modified time of both ~/.gitconfig and $GIT_DIR?config. If
$GIT_DIR/config appears to have been modified, it is read back in
from disk and the current config is wiped out.
When mutating a configuration file, this may cause in-memory edits
to disappear. To avoid that callers need to avoid calling getConfig
until after the configuration has been saved to disk.
Unfortunately the API is still horribly broken. Configuration should
be modified only while a lock is held on the configuration file, very
similar to the way a ref is updated via its locking protocol. But our
existing API is really broken for that so we'll have to defer cleaning
up the edit path for a future change.
Change-Id: I5888dd97bac20ddf60456c81ffc1eb8df04ef410
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java index 2057020cdf..6044f2599a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java @@ -182,9 +182,9 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { workdir.mkdir(); FileRepository repo1initial = new FileRepository(new File(repo1Parent, Constants.DOT_GIT)); repo1initial.create(); - repo1initial.getConfig().setString("core", null, "worktree", - workdir.getAbsolutePath()); - repo1initial.getConfig().save(); + final FileBasedConfig cfg = repo1initial.getConfig(); + cfg.setString("core", null, "worktree", workdir.getAbsolutePath()); + cfg.save(); repo1initial.close(); File theDir = new File(repo1Parent, Constants.DOT_GIT); @@ -207,9 +207,9 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { workdir.mkdir(); FileRepository repo1initial = new FileRepository(new File(repo1Parent, Constants.DOT_GIT)); repo1initial.create(); - repo1initial.getConfig() - .setString("core", null, "worktree", "../../rw"); - repo1initial.getConfig().save(); + final FileBasedConfig cfg = repo1initial.getConfig(); + cfg.setString("core", null, "worktree", "../../rw"); + cfg.save(); repo1initial.close(); File theDir = new File(repo1Parent, Constants.DOT_GIT); |