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
110 &mut self,110 &mut self,
111 repo: &'repo mut crate::Repository,111 repo: &'repo mut crate::Repository,
112 ) -> Result<&'repo mut crate::Repository, crate::config::Error> {112 ) -> Result<&'repo mut crate::Repository, crate::config::Error> {
113 repo.config113 repo.reread_values_and_clear_caches_replacing_config(std::mem::take(&mut self.config).into())?;
114 .reread_values_and_clear_caches_replacing_config(std::mem::take(&mut self.config).into())?;
115 Ok(repo)114 Ok(repo)
116 }115 }
117 116
@@ -145,8 +144,7 @@ impl<'repo> CommitAutoRollback<'repo> { · 27 unmodified lines
145 &mut self,144 &mut self,
146 repo: &'repo mut crate::Repository,145 repo: &'repo mut crate::Repository,
147 ) -> Result<&'repo mut crate::Repository, crate::config::Error> {146 ) -> Result<&'repo mut crate::Repository, crate::config::Error> {
148 repo.config147 repo.reread_values_and_clear_caches_replacing_config(OwnShared::clone(&self.prev_config))?;
149 .reread_values_and_clear_caches_replacing_config(OwnShared::clone(&self.prev_config))?;
150 Ok(repo)148 Ok(repo)
151 }149 }
152}150}
git-repository/src/open.rs+11−1
@@ -463,12 +463,22 @@ impl Repository { · 462 unmodified lines
463 ///463 ///
464 /// Similar to `reread_values_and_clear_caches_replacing_config()`, but works on the existing instance instead of a passed464 /// Similar to `reread_values_and_clear_caches_replacing_config()`, but works on the existing instance instead of a passed
465 /// in one that it them makes the default.465 /// 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> {
467 self.config.reread_values_and_clear_caches()?;467 self.config.reread_values_and_clear_caches()?;
468 self.apply_changed_values();468 self.apply_changed_values();
469 Ok(())469 Ok(())
470 }470 }
471 471
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
472 fn apply_changed_values(&mut self) {482 fn apply_changed_values(&mut self) {
473 self.refs.write_reflog = reflog_or_default(self.config.reflog, self.work_dir().is_some());483 self.refs.write_reflog = reflog_or_default(self.config.reflog, self.work_dir().is_some());
474 }484 }