Repository navigation
Match globs with :(glob) pathspecs: **/*.md now includes root files - #28
Merged
Merged
Conversation
ndbroadbent
added a commit
that referenced
this pull request
Dec 4, 2026
Globs were passed to git ls-files as plain pathspecs and retried with :(glob) only when nothing matched. Without glob magic, **/ can't match zero directories, so **/*.md missed README.md and docs/**/*.md missed docs/a.md whenever a deeper file matched: a change to those files skipped the job. Plain pathspecs also let * cross directories, so *.md matched every directory. src/pathspec.rs now matches every glob cigen hashes (inputs, groups, module inputs, hash --pattern) one way: git ls-files -z with :(glob), or, outside git, the same rules over the files on disk with globset. globwalk is gone. This changes which files many globs match, so most job hashes change once: every job with inputs runs again on its first push after upgrading. Found converting a real project's CI. tests/glob_inputs.rs checks each rule inside and outside git, and fails on the old matching.
…he root only A glob with no slash matches at any depth and a leading / or ./ anchors it, as in gitignore, so the rules err towards including. git gets two :(glob) pathspecs, the glob and <glob>/**, so a glob that matches a directory brings every file under it; the disk fallback uses the same two globs. Tests cover *.md at depth, /*.md at the root only and docs/*.md missing docs/sub/x.md.
ndbroadbent
force-pushed
the
fix/glob-pathspec
branch
from
December 4, 2026 02:06
bc4df8b to
1a7fa75
Compare
…rks in container jobs In a CI container job the checkout is owned by another user, and git refuses with "detected dubious ownership". git accepts safe.directory on the command line and matches it against the repository's top level, so src/git.rs finds the nearest directory holding .git and every git command cigen runs goes through it. The old matching hid this: when git ls-files failed it silently globbed the files on disk. STATUS records that as known problem 21 (resolved). tests/git_ownership.rs reproduces the failure with git's GIT_TEST_ASSUME_DIFFERENT_OWNER, at the root and in a subdirectory.
This was referenced Dec 4, 2026
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.
A false-skip fix. Globs were passed to
git ls-filesas plain pathspecs, and retried with:(glob)only when nothing matched. Without glob magic,**/can't match zero directories:**/*.mdd/a.md d/sub/b.md, notREADME.mdREADME.md d/a.md d/sub/b.mdd/**/*.mdd/sub/b.md, notd/a.mdd/a.md d/sub/b.md*.md.mdin every directory.mdin every directory (unchanged)/*.mdREADME.mdonlyd/*.mdd/a.md d/sub/b.mdd/a.mdonlySo a commit that only changed
README.mdskipped a job whose inputs were**/*.md. Two live examples: bootstrap's cspell job (found while converting its CI for a case study), and cigen's own.cigen/**/*.yml, which missed.cigen/config.yml.The fix:
src/pathspec.rsis now the one place globs are matched, for job and groupinputs, module inputs andcigen hash --pattern, with gitignore's rules, which err towards including: a glob with no/matches at any depth (*.mdis**/*.md), a leading/or./anchors it to the root, and a glob with a/elsewhere is matched from the root with*staying in one directory. Each pattern becomes two root-relative globs,<glob>and<glob>/**, so a glob that matches a directory brings every file under it. In git they go togit ls-files -zas:(glob)pathspecs (tracked files only,LC_ALL=Cso "not a git repository" is recognised). Outside git the same two globs are applied to the files on disk withglobset(literal_separator).globwalkis removed.A file name with no
/now matches in every directory:Cargo.lockincludestools/Cargo.lock. That's over-inclusive, the safe direction. The rust module's root inputs (Cargo.lockwhenpath: .) are affected the same way; anchoring them with/is a possible follow-up.I checked for the same bug class elsewhere. Derived inputs list local actions with walkdir and use no globs, no provider emits
hashFiles, and mockci's globset only simulates GitHub's own filters.Hashes change. Many globs now match different files, so most job hashes change once, and every job with
inputsruns again on its first push after upgrading. That's the safe direction. STATUS records it as known problem 20 (resolved). The inputs docs have a table of the rules.Tests:
tests/glob_inputs.rschecks each rule twice, in a git repository and in a plain directory, and requires the two to agree. Each case changes one file and checks whether the job's hash changes:*.mdat depth,/*.mdand./*.mdat the root only,docs/*.mdnot matchingdocs/guide/b.md, and a bare directory name at any depth. A unit test pins how each pattern is rewritten. The**/tests fail on the old matching;hash --patternalready matched root files through globwalk, and that test now pins it to the same rules as inputs.task cipasses with no warnings.Note for #14 (
cigen explain):src/hashing/files.rscarries a copy of the oldlist_files. On rebase it should callcigen::pathspec::list_filesinstead.Container jobs (second commit). CI's container jobs (
rust:latest) failed at the hash step:git ls-filesrefused with "detected dubious ownership", because the checkout belongs to another uid. Every user with a container job would hit it.src/git.rsnow builds every git command cigen runs with-c safe.directory=<repository root>. git accepts that on the command line (checked with git 2.47.3 inrust:latest) but matches it against the repository's top level, not the directory git runs in, so cigen finds the nearest directory holding.git; the project root alone fails when the project is a subdirectory.The old matching hid this: when
git ls-filesfailed for any reason it silently globbed the files on disk, untracked files and build output included, so container jobs hashed a different file list. STATUS records that as known problem 21 (resolved). Any other git error now fails with git's message.tests/git_ownership.rsreproduces the failure with git's ownGIT_TEST_ASSUME_DIFFERENT_OWNER(honoured by 2.47 and 2.56), at the repository root and with the project in a subdirectory, and checks the hash matches the owner's. Both tests fail without the fix with the same error CI showed. A unit test pins the-c safe.directoryargument.