Repository navigation
fix: a glob's **/ stands for whole directories, not part of a name - #878
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
relative_path_matches_glob consumed `**/` and then retried the rest of the pattern at every character of the path, so what followed `**/` could begin in the middle of a file or directory name. `**/main.cpp` selected `src/domain.cpp`, `tests/**/test_*.cpp` selected `tests/mytest_a.cpp`, and `**/modules/dnn/**/*.avx2.cpp` selected `a/submodules/dnn/l.avx2.cpp`. The matcher serves every glob with the `sources` grammar: `sources`, `[build] flags`, `[scan_overrides]`, test `discover`, `[pack] include`/`exclude`, include-dir globs and `rerun_if_changed_glob`. A `[build] flags` entry for `**/main.cpp` therefore also compiled `src/app/domain.cpp` with its defines. After `**/` the rest of the pattern now resumes only where it stands (zero directories) or just after a `/`. A `**` not followed by `/` (`src/**`, `src/**.cpp`) keeps crossing segments and names as before. The literal-prefix and tail pre-filters of expand_glob are supersets of the new match and are unchanged. Tests: Glob.ADoubleStarSlashStandsForWholeDirectories checks the matcher directly, and Scanner.ADoubleStarSlashTailMatchesAtTheRoot gains a `sub/domain.cpp` that the `**/main.cpp` walk must not return. docs/04 states the rule in both languages. Closes mcpp-community#877
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
relative_path_matches_globconsumed**/and then retried the rest of the pattern at every character of the path, so what followed**/could begin in the middle of a name.**/main.cppselectedsrc/domain.cpp,tests/**/test_*.cppselectedtests/mytest_a.cpp, and**/modules/dnn/**/*.avx2.cppselecteda/submodules/dnn/l.avx2.cpp. The matcher serves every glob with thesourcesgrammar (sources,[build] flags,[scan_overrides], testdiscover,[pack] include/exclude, include-dir globs,rerun_if_changed_glob), so a[build] flagsentry for**/main.cppalso compiledsrc/app/domain.cppwith its defines.After
**/, the rest of the pattern now resumes only where it stands (zero directories) or just after a/. A**not followed by/(src/**,src/**.cpp) still crosses segments and names. The literal-prefix and tail pre-filters ofexpand_globselect a superset of the new matches and are unchanged.docs/04-mcpp-toml.mdstates the rule in both languages.Closes #877.
Criteria
Glob.ADoubleStarSlashStandsForWholeDirectories(tests/unit/test_modgraph.cpp) checks the matcher directly:**/main.cppagainstmain.cpp,src/main.cpp,src/a/b/main.cppand threedomain.cpppaths;tests/**/test_*.cpp; the**/modules/dnn/**/*.avx2.cppform from test_manifest; andsrc/**,src/**.cpp,**, which keep their meaning.Scanner.ADoubleStarSlashTailMatchesAtTheRootgains asub/domain.cppthat the**/main.cppwalk must not return. On aarch64 Linux with the released 2026.10.31.3 binary,mcpp test test_modgraphfails both before the change (the walk returns 3 files; sixdomain/mytest/submodulescases match) and passes after it.mcpp test, 160 passed, 0 failed) passes on aarch64 Linux. Other hosts are left to CI.**/matches part of a name, so**/main.cppselectssrc/domain.cpp#877 (flags = [ { glob = "**/main.cpp", defines = ["ENTRY_ONLY"] } ],src/main.cpp,src/app/domain.cppthat#errors underENTRY_ONLY, andsrc/main.cppthat#errors without it): the released binary fails onobj/domain.o. The binary built from this branch builds and runs it, so the define reachessrc/main.cppand only it.Intersections
**/resumes only at a segment start**/also matches no directory:**/main.cppmatches a rootmain.cppScanner.ADoubleStarSlashTailMatchesAtTheRoot, themain.cppcase of the new testexpand_globpre-filters by literal prefix and literal tail before matchingScanner.ExpandGlobStartsAtLiteralPrefix*,Scanner.ADoubleStarSlashTailMatchesAtTheRoot**and a**inside a segment cross segmentssrc/**,src/**.cppand**cases of the new test,Scanner.PerGlobFlagsAttachToMatchedUnits(third_party/**)Scanner.ExpandGlobBraceAlternation,Scanner.PerGlobFlagsMatchBraceAlternationCompatibility
A glob with
**/no longer selects a file or directory whose name only ends with the text after it. A project that relied on that, such as**/main.cppmeant to pickdomain.cpp, now selects fewer files; a[scan_overrides]glob that only matched that way becomes an unmatched glob and is reported. Every glob without**/, and every path that starts a segment where the pattern resumes, matches as before. No cache key or output format changes.Checks before merging
bash .github/tools/check_docs_style.sh,check_docs_structure.shandcheck_version_pins.shpass.python3 .github/tools/check_workflow_assertions.pypasses (a step asserts what its name says).git log origin/main..HEAD -i --grep='Co-Authored-By'prints nothing.compose one from the branch's commits. Suggested subject:
fix: a glob's**/stands for whole directories, not part of a name.