Skip to content

Commit dd57957

Browse files
committed
improve the error message around incorrect worktree paths
1 parent 886289f commit dd57957

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

gix/src/config/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ pub enum Error {
9191
ResolveIncludes(#[from] gix_config::file::includes::Error),
9292
#[error(transparent)]
9393
FromEnv(#[from] gix_config::file::init::from_env::Error),
94-
#[error(transparent)]
95-
PathInterpolation(#[from] gix_config::path::interpolate::Error),
94+
#[error("The path {path:?} at the 'core.worktree' configuration could not be interpolated")]
95+
PathInterpolation {
96+
path: BString,
97+
source: gix_config::path::interpolate::Error,
98+
},
9699
#[error("{source:?} configuration overrides at open or init time could not be applied.")]
97100
ConfigOverrides {
98101
#[source]

gix/src/open/repository.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,13 @@ impl ThreadSafeRepository {
237237
.resolved
238238
.path_filter("core", None, Core::WORKTREE.name, &mut filter_config_section)
239239
{
240+
let wt_clone = wt.clone();
240241
let wt_path = wt
241242
.interpolate(interpolate_context(git_install_dir.as_deref(), home.as_deref()))
242-
.map_err(config::Error::PathInterpolation)?;
243+
.map_err(|err| config::Error::PathInterpolation {
244+
path: wt_clone.value.into_owned(),
245+
source: err,
246+
})?;
243247
worktree_dir = gix_path::normalize(git_dir.join(wt_path).into(), current_dir).map(Cow::into_owned);
244248
#[allow(unused_variables)]
245249
if let Some(worktree_path) = worktree_dir.as_deref().filter(|wtd| !wtd.is_dir()) {

gix/tests/repository/open.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn non_bare_split_worktree_invalid_worktree_path_empty() -> crate::Result {
7474
)
7575
.unwrap_err();
7676
assert!(
77-
matches!(err, gix::open::Error::Config(gix::config::Error::PathInterpolation(_))),
77+
matches!(err, gix::open::Error::Config(gix::config::Error::PathInterpolation{..})),
7878
"DEVIATION: could not read path at core.worktree as empty is always invalid, git tries to use an empty path, even though it's better to reject it"
7979
);
8080
Ok(())

0 commit comments

Comments
 (0)