Skip to content

Fix .dockerignore wildcard negation directory descent#6927

Open
Honny1 wants to merge 1 commit into
podman-container-tools:mainfrom
Honny1:negation-filter
Open

Fix .dockerignore wildcard negation directory descent#6927
Honny1 wants to merge 1 commit into
podman-container-tools:mainfrom
Honny1:negation-filter

Conversation

@Honny1

@Honny1 Honny1 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Buildah skipped excluded directories when negation patterns contained wildcards (For example: !**/*.go), because the descent check only matched literal prefixes. Extract the literal prefix before the first wildcard and descend when the directory is at or under it; when the prefix is empty, always descend.

Same bug as Docker's classic builder (moby/moby#30018, moby/moby#45608).

Fixes: #6615

What type of PR is this?

/kind api-change
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind other

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fixed `.dockerignore`/`.containerignore` handling of wildcard negation patterns (e.g. `!**/*.go`, `!*/*.go`). Previously, files matching these patterns inside excluded directories were incorrectly omitted from the build context.

@Honny1 Honny1 force-pushed the negation-filter branch from d6e291e to fcba319 Compare June 24, 2026 13:52
Buildah skipped excluded directories when negation patterns contained
wildcards (For example: !**/*.go), because the descent check only matched
literal prefixes. Extract the literal prefix before the first wildcard
and descend when the directory is at or under it; when the prefix is
empty, always descend.

Same bug as Docker's classic builder (moby/moby#30018, moby/moby#45608).

Fixes: podman-container-tools#6615

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
@Honny1 Honny1 force-pushed the negation-filter branch from fcba319 to f65f4ed Compare June 25, 2026 08:26
@Honny1 Honny1 marked this pull request as ready for review June 25, 2026 08:44
@Honny1

Honny1 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

PTAL @podman-container-tools/buildah-maintainers @podman-container-tools/buildah-reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dockerignore prevents build from working

1 participant