@@ -174,20 +174,30 @@ fn home_conf_file() -> Option<PathBuf> {
174174/// If the target location is in a Git repository, construct the path
175175/// to a configuration file at the repository's root.
176176/// Find all such configuration files if the Git repository is nested.
177- fn git_conf_files ( target_dir : & Path ) -> Vec < PathBuf > {
177+ fn git_conf_files ( target_dir : & Path ) -> Result < Vec < PathBuf > > {
178+ let absolute_path = target_dir
179+ . canonicalize ( )
180+ . wrap_err ( "Failed to construct the absolute path to the target directory." ) ?;
178181 // Find all ancestor directories that appear to be the root of a Git repo.
179- let git_roots = target_dir . ancestors ( ) . filter ( |dir| {
182+ let git_roots = absolute_path . ancestors ( ) . filter ( |dir| {
180183 // The simple heuristic is that the directory is the Git root if it contains
181184 // the `.git/` sub-directory.
182185 let git_dir = dir. join ( ".git" ) ;
186+ log:: debug!(
187+ "Testing this directory as a Git repo root: {}" ,
188+ git_dir. display( )
189+ ) ;
183190 git_dir. is_dir ( )
184191 } ) ;
185192
186193 let config_files: Vec < _ > = git_roots
187- . map ( |root| root. join ( config_file_name ( true ) ) )
194+ . map ( |root| {
195+ log:: debug!( "Found a Git repo root: {}" , root. display( ) ) ;
196+ root. join ( config_file_name ( true ) )
197+ } )
188198 . collect ( ) ;
189199
190- config_files
200+ Ok ( config_files)
191201}
192202
193203/// Combine the configuration found on the command line, in configuration files,
@@ -210,7 +220,7 @@ pub fn merge_configs(cli: &Cli) -> Result<Options> {
210220 } ;
211221
212222 // All config files in Git repo roots:
213- let mut git_conf_files = git_conf_files ( & cli. common_options . target_dir ) ;
223+ let mut git_conf_files = git_conf_files ( & cli. common_options . target_dir ) ? ;
214224 // Reverse their order so that the inner repo configuration takes precedence over outer:
215225 git_conf_files. reverse ( ) ;
216226 // Load each Git repo configuration file:
0 commit comments