From 2b9ffdf3f7451b5ccf5acf780859ccecf9af1d15 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 17 Dec 2024 16:53:38 +0900 Subject: [PATCH] cli: normalize repository path specified by -R This will simplify path comparison in config resolver. /.. shouldn't match path prefix . Maybe we should do path canonicalization globally (or never do canonicalization), but I'm not sure where that should be made. --- cli/src/cli_util.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 7d3ffe1212..2587e47f74 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -3677,10 +3677,13 @@ impl CliRunner { } let maybe_workspace_loader = if let Some(path) = &args.global_args.repository { + // TODO: maybe path should be canonicalized by WorkspaceLoader? + let abs_path = cwd.join(path); + let abs_path = abs_path.canonicalize().unwrap_or(abs_path); // Invalid -R path is an error. No need to proceed. let loader = self .workspace_loader_factory - .create(&cwd.join(path)) + .create(&abs_path) .map_err(|err| map_workspace_load_error(err, Some(path)))?; config_env.reset_repo_path(loader.repo_path()); config_env.reload_repo_config(&mut config)?;