History

refactor

- use improved API in git-config - expose `plumbing` directly via AsDeref.

Sebastian Thiel committed 3 years ago

Commit 603f3411 parent f1a4c8b3 files · +11 −16Browse files

Unified · Split

3 files
  1. git-repository/src/config/snapshot/_impls.rs +8 −0
  2. git-repository/src/config/snapshot/access.rs +3 −15
  3. gitoxide-core/src/repository/config.rs +0 −1
git-repository/src/config/snapshot/_impls.rs+8−0
@@ -47,6 +47,14 @@ impl Deref for SnapshotMut<'_> { · 46 unmodified lines
4747 }
4848 }
4949
50+impl Deref for Snapshot<'_> {
51+ type Target = git_config::File<'static>;
52+
53+ fn deref(&self) -> &Self::Target {
54+ &self.plumbing()
55+ }
56+}
57+
5058 impl Deref for CommitAutoRollback<'_> {
5159 type Target = crate::Repository;
5260
git-repository/src/config/snapshot/access.rs+3−15
@@ -25,11 +25,7 @@ impl<'repo> Snapshot<'repo> { · 24 unmodified lines
2525
2626 /// Like [`boolean()`][Self::boolean()], but it will report an error if the value couldn't be interpreted as boolean.
2727 pub fn try_boolean<'a>(&self, key: impl Into<&'a BStr>) -> Option<Result<bool, git_config::value::Error>> {
28− let key = git_config::parse::key(key)?;
29− self.repo
30− .config
31− .resolved
32− .boolean(key.section_name, key.subsection_name, key.value_name)
28+ self.repo.config.resolved.boolean_by_key(key)
3329 }
3430
3531 /// Return the resolved integer at `key`, or `None` if there is no such value or if the value can't be interpreted as
@@ -44,22 +40,14 @@ impl<'repo> Snapshot<'repo> { · 8 unmodified lines
4440
4541 /// Like [`integer()`][Self::integer()], but it will report an error if the value couldn't be interpreted as boolean.
4642 pub fn try_integer<'a>(&self, key: impl Into<&'a BStr>) -> Option<Result<i64, git_config::value::Error>> {
47− let key = git_config::parse::key(key)?;
48− self.repo
49− .config
50− .resolved
51− .integer(key.section_name, key.subsection_name, key.value_name)
43+ self.repo.config.resolved.integer_by_key(key)
5244 }
5345
5446 /// Return the string at `key`, or `None` if there is no such value.
5547 ///
5648 /// Note that this method takes the most recent value at `key` even if it is from a file with reduced trust.
5749 pub fn string<'a>(&self, key: impl Into<&'a BStr>) -> Option<Cow<'_, BStr>> {
58− let key = git_config::parse::key(key)?;
59− self.repo
60− .config
61− .resolved
62− .string(key.section_name, key.subsection_name, key.value_name)
50+ self.repo.config.resolved.string_by_key(key)
6351 }
6452
6553 /// Return the trusted and fully interpolated path at `key`, or `None` if there is no such value
gitoxide-core/src/repository/config.rs+0−1
@@ -19,7 +19,6 @@ pub fn list( · 18 unmodified lines
1919 repo.open_options().clone().lossy_config(false).cli_overrides(overrides),
2020 )?;
2121 let config = repo.config_snapshot();
22− let config = config.plumbing();
2322 if let Some(frontmatter) = config.frontmatter() {
2423 for event in frontmatter {
2524 event.write_to(&mut out)?;