Skip to content

Commit

Permalink
Use a more gitignore style matching
Browse files Browse the repository at this point in the history
Use a rightmost match for / so that if we end up with a Section: a/b/c,
a 'c' matcher still matches.

If the section does not contain any /, it can be matched using /pattern,
e.g. /c only matches Section: c, but not Section: a/b/c.
  • Loading branch information
julian-klode committed Feb 27, 2023
1 parent 0899b69 commit 557aed9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apt-pkg/depcache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ static bool SectionInSubTree(char const * const SubTree, std::string_view Needle
{
if (ConfigValueInSubTree(SubTree, Needle))
return true;
auto const sub = Needle.find('/');
auto const sub = Needle.rfind('/');
if (sub == std::string_view::npos)
{
std::string special{"<undefined>/"};
std::string special{"/"};
special.append(Needle);
return ConfigValueInSubTree(SubTree, special);
}
Expand Down
4 changes: 2 additions & 2 deletions cmdline/apt-mark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ static bool SectionInSubTree(char const * const SubTree, std::string_view Needle
{
if (ConfigValueInSubTree(SubTree, Needle))
return true;
auto const sub = Needle.find('/');
auto const sub = Needle.rfind('/');
if (sub == std::string_view::npos)
{
std::string special{"<undefined>/"};
std::string special{"/"};
special.append(Needle);
return ConfigValueInSubTree(SubTree, special);
}
Expand Down

0 comments on commit 557aed9

Please sign in to comment.