aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-18 21:33:34 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-09-20 16:30:44 +0300
commit592570fb39f52f1d766aede5f84838e0dc7f4c87 (patch)
tree5796fdeed3478bf4756191a563a956c1db428e80
parent1ad6dad8da0d51e9522f9d27cf48531fa23b24ba (diff)
Adapt to bracket expressions in wildcard patterns
-rw-r--r--bpkg/fetch-git.cxx19
1 files changed, 17 insertions, 2 deletions
diff --git a/bpkg/fetch-git.cxx b/bpkg/fetch-git.cxx
index 28557f8..6638399 100644
--- a/bpkg/fetch-git.cxx
+++ b/bpkg/fetch-git.cxx
@@ -10,7 +10,7 @@
#include <libbutl/git.mxx>
#include <libbutl/utility.mxx> // digit(), xdigit()
#include <libbutl/process.mxx>
-#include <libbutl/filesystem.mxx> // path_match(), path_entry()
+#include <libbutl/filesystem.mxx> // path_{entry,match,pattern}()
#include <libbutl/semantic-version.mxx>
#include <libbutl/standard-version.mxx> // parse_standard_version()
@@ -692,7 +692,22 @@ namespace bpkg
search_names (const string& n, bool abbr_commit) const
{
search_result r;
- bool pattern (n.find_first_of ("*?") != string::npos);
+ bool pattern (false);
+
+ // If the name is not a valid path, then we don't consider it as a
+ // pattern.
+ //
+ // Note that creating a path starting with '/' (that we use for
+ // anchoring search to refs; see below for details) fails on Windows, so
+ // we strip it.
+ //
+ try
+ {
+ pattern = path_pattern (path (n[0] != '/'
+ ? n.c_str ()
+ : n.c_str () + 1));
+ }
+ catch (const invalid_path&) {}
auto search = [this, pattern, &r] (const string& n)
{