|
| 1 | +use crate::config::tree::{Key, Mailmap}; |
| 2 | +use crate::Id; |
| 3 | + |
1 | 4 | impl crate::Repository { |
2 | 5 | // TODO: tests |
3 | 6 | /// Similar to [`open_mailmap_into()`][crate::Repository::open_mailmap_into()], but ignores all errors and returns at worst |
@@ -27,12 +30,11 @@ impl crate::Repository { |
27 | 30 | let mut blob_id = self |
28 | 31 | .config |
29 | 32 | .resolved |
30 | | - .raw_value("mailmap", None, "blob") |
31 | | - .ok() |
| 33 | + .string("mailmap", None, Mailmap::BLOB.name) |
32 | 34 | .and_then(|spec| { |
33 | | - // TODO: actually resolve this as spec (once we can do that) |
34 | | - gix_hash::ObjectId::from_hex(spec.as_ref()) |
| 35 | + self.rev_parse_single(spec.as_ref()) |
35 | 36 | .map_err(|e| err.get_or_insert(e.into())) |
| 37 | + .map(Id::detach) |
36 | 38 | .ok() |
37 | 39 | }); |
38 | 40 | match self.work_dir() { |
@@ -69,29 +71,9 @@ impl crate::Repository { |
69 | 71 | } |
70 | 72 |
|
71 | 73 | let configured_path = self |
72 | | - .config |
73 | | - .resolved |
74 | | - .value::<gix_config::Path<'_>>("mailmap", None, "file") |
75 | | - .ok() |
76 | | - .and_then(|path| { |
77 | | - let install_dir = self.install_dir().ok()?; |
78 | | - let home = self.config.home_dir(); |
79 | | - match path.interpolate(gix_config::path::interpolate::Context { |
80 | | - git_install_dir: Some(install_dir.as_path()), |
81 | | - home_dir: home.as_deref(), |
82 | | - home_for_user: if self.options.git_dir_trust.expect("trust is set") == gix_sec::Trust::Full { |
83 | | - Some(gix_config::path::interpolate::home_for_user) |
84 | | - } else { |
85 | | - None |
86 | | - }, |
87 | | - }) { |
88 | | - Ok(path) => Some(path), |
89 | | - Err(e) => { |
90 | | - err.get_or_insert(e.into()); |
91 | | - None |
92 | | - } |
93 | | - } |
94 | | - }); |
| 74 | + .config_snapshot() |
| 75 | + .trusted_path(Mailmap::FILE.logical_name().as_str()) |
| 76 | + .and_then(|res| res.map_err(|e| err.get_or_insert(e.into())).ok()); |
95 | 77 |
|
96 | 78 | if let Some(mut file) = |
97 | 79 | configured_path.and_then(|path| std::fs::File::open(path).map_err(|e| err.get_or_insert(e.into())).ok()) |
|
0 commit comments