Skip to content

Commit 9793511

Browse files
committed
refactor
- use improved API in git-config - expose `plumbing` directly via AsDeref.
1 parent ad1a80c commit 9793511

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

git-repository/src/config/snapshot/_impls.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ impl Deref for SnapshotMut<'_> {
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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ impl<'repo> Snapshot<'repo> {
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> {
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub fn list(
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)?;

0 commit comments

Comments
 (0)