From 0b226865d5ba23b07711e28038f9fa5b520c0afc Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 4 Nov 2023 11:39:18 +0100 Subject: [PATCH] Fix cda6f24f: don't ignore binary-dir if it happens to be working-dir (#11431) Some of our code ignores the SP_WORKING_DIR for some actions, which means that if, for example, your SP_BINARY_DIR is the same as your SP_WORKING_DIR, neither is scanned. Instead, only add SP_WORKING_DIR if it is unique. (cherry picked from commit c059ce0c97b653914e94808ef2e2a8c9e0ff75ad) --- src/fileio.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/fileio.cpp b/src/fileio.cpp index 6e165e96ba..b9940b98dc 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -88,6 +88,8 @@ static void FillValidSearchPaths(bool only_local_path) btree::btree_set seen{}; for (Searchpath sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) { + if (sp == SP_WORKING_DIR) continue; + if (only_local_path) { switch (sp) { case SP_WORKING_DIR: // Can be influence by "-c" option. @@ -106,6 +108,13 @@ static void FillValidSearchPaths(bool only_local_path) _valid_searchpaths.emplace_back(sp); } } + + /* The working-directory is special, as it is controlled by _do_scan_working_directory. + * Only add the search path if it isn't already in the set. To preserve the same order + * as the enum, insert it in the front. */ + if (IsValidSearchPath(SP_WORKING_DIR) && seen.count(_searchpaths[SP_WORKING_DIR]) == 0) { + _valid_searchpaths.insert(_valid_searchpaths.begin(), SP_WORKING_DIR); + } } /**