History

Fully reload in-memory configuration after configuration changes… (#450)

…even though there is still something fishy about the configuration that we create as it apparenlty is unable to see the overrides. Is it a filter, maybe?

Sebastian Thiel committed 4 years ago

Commit bc5b4e71 parent ff06de42 files · +13 −5Browse files

Unified · Split

2 files
  1. git-repository/src/config/snapshot/access.rs +2 −4
  2. git-repository/src/open.rs +11 −1
git-repository/src/config/snapshot/access.rs+2−4
@@ -110,8 +110,7 @@ impl<'repo> SnapshotMut<'repo> { · 109 unmodified lines
110110 &mut self,
111111 repo: &'repo mut crate::Repository,
112112 ) -> Result<&'repo mut crate::Repository, crate::config::Error> {
113− repo.config
114− .reread_values_and_clear_caches_replacing_config(std::mem::take(&mut self.config).into())?;
113+ repo.reread_values_and_clear_caches_replacing_config(std::mem::take(&mut self.config).into())?;
115114 Ok(repo)
116115 }
117116
@@ -145,8 +144,7 @@ impl<'repo> CommitAutoRollback<'repo> { · 27 unmodified lines
145144 &mut self,
146145 repo: &'repo mut crate::Repository,
147146 ) -> Result<&'repo mut crate::Repository, crate::config::Error> {
148− repo.config
149− .reread_values_and_clear_caches_replacing_config(OwnShared::clone(&self.prev_config))?;
147+ repo.reread_values_and_clear_caches_replacing_config(OwnShared::clone(&self.prev_config))?;
150148 Ok(repo)
151149 }
152150 }
git-repository/src/open.rs+11−1
@@ -463,12 +463,22 @@ impl Repository { · 462 unmodified lines
463463 ///
464464 /// Similar to `reread_values_and_clear_caches_replacing_config()`, but works on the existing instance instead of a passed
465465 /// in one that it them makes the default.
466− pub fn reread_values_and_clear_caches(&mut self) -> Result<(), config::Error> {
466+ pub(crate) fn reread_values_and_clear_caches(&mut self) -> Result<(), config::Error> {
467467 self.config.reread_values_and_clear_caches()?;
468468 self.apply_changed_values();
469469 Ok(())
470470 }
471471
472+ /// Replace our own configuration with `config` and re-read all cached values, and apply them to select in-memory instances.
473+ pub(crate) fn reread_values_and_clear_caches_replacing_config(
474+ &mut self,
475+ config: crate::Config,
476+ ) -> Result<(), config::Error> {
477+ self.config.reread_values_and_clear_caches_replacing_config(config)?;
478+ self.apply_changed_values();
479+ Ok(())
480+ }
481+
472482 fn apply_changed_values(&mut self) {
473483 self.refs.write_reflog = reflog_or_default(self.config.reflog, self.work_dir().is_some());
474484 }