From 592570fb39f52f1d766aede5f84838e0dc7f4c87 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 18 Sep 2019 21:33:34 +0300 Subject: Adapt to bracket expressions in wildcard patterns --- bpkg/fetch-git.cxx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'bpkg') 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 #include // digit(), xdigit() #include -#include // path_match(), path_entry() +#include // path_{entry,match,pattern}() #include #include // 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) { -- cgit v1.1