fix: Respect dirty .gitignore patterns during task input hashing#12557
Merged
anthonyshew merged 1 commit intomainfrom Apr 5, 2026
Merged
fix: Respect dirty .gitignore patterns during task input hashing#12557anthonyshew merged 1 commit intomainfrom
anthonyshew merged 1 commit intomainfrom
Conversation
When .gitignore is modified but not yet committed, its stat no longer matches the git index entry, so it gets classified as Modified and placed in status_entries rather than ls_tree_hashes. The gitignore matcher construction in find_untracked_files() only scanned ls_tree_hashes, causing the dirty .gitignore to be invisible — its patterns were silently dropped and gitignored paths like node_modules/ leaked into task input hashes. Now scan both ls_tree_hashes and status_entries for .gitignore files. Fixes #12554
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
github-actions Bot
added a commit
that referenced
this pull request
Apr 5, 2026
## Release v2.9.4 Versioned docs: https://v2-9-4.turborepo.dev ### Changes - release(turborepo): 2.9.3 (#12524) (`0b48404`) - fix: Always update $schema URL to versioned format during migration (#12529) (`389cd5e`) - release(turborepo): 2.9.4-canary.1 (#12530) (`7f8cb9a`) - fix: Support `turbo.jsonc` in codemod transforms (#12532) (`e570d29`) - feat: Add incremental task caching (#12531) (`39c4934`) - release(turborepo): 2.9.4-canary.2 (#12533) (`d2944c4`) - docs: Send siteId as label on feedback GitHub issues (#12527) (`6644f34`) - Replace local ai-agent-detection with @vercel/agent-readability (#12528) (`86d34cc`) - fix: Prevent `filterUsingTasks` `--filter` from pulling dependents into Task Graph (#12535) (`d3aca27`) - release(turborepo): 2.9.4-canary.3 (#12536) (`074a0ef`) - build(deps): Bump @xmldom/xmldom from 0.8.11 to 0.8.12 in /examples/with-react-native-web (#12537) (`295a89b`) - fix: Only enforce signature key length for keys that exist (#12538) (`27ac52f`) - release(turborepo): 2.9.4-canary.4 (#12539) (`f745fc7`) - fix: Validate engine concurrency after task-level filtering (#12540) (`a38658a`) - release(turborepo): 2.9.4-canary.5 (#12541) (`ac99fac`) - fix: Preserve prerelease info in schema URL during codemod migration (#12542) (`81b39a5`) - feat: Allow `--affected` and `--filter` to be combined (#12543) (`98ab3b6`) - fix(config): Deep-merge nested OTEL config across priority sources (#12513) (`f214dc8`) - release(turborepo): 2.9.4-canary.6 (#12544) (`0e763f8`) - fix: Retain microfrontend proxy tasks when using `filterUsingTasks` (#12545) (`a4b943e`) - release(turborepo): 2.9.4-canary.7 (#12546) (`b7d89a4`) - fix: Bun workspace lockfile pruning producing invalid output (#12548) (`0346076`) - fix: Respect dirty .gitignore patterns during task input hashing (#12557) (`1254916`) - release(turborepo): 2.9.4-canary.8 (#12558) (`01802b4`) --------- Co-authored-by: Turbobot <turbobot@vercel.com>
github-actions Bot
added a commit
that referenced
this pull request
Apr 6, 2026
## Release v2.9.5-canary.1 Versioned docs: https://v2-9-5-canary-1.turborepo.dev ### Changes - fix: Respect dirty .gitignore patterns during task input hashing (#12557) (`1254916`) - release(turborepo): 2.9.4-canary.8 (#12558) (`01802b4`) - release(turborepo): 2.9.4 (#12559) (`20dfb78`) - feat: Replace package manager commands in scaffolded README files (#6747) (`8f6f012`) Co-authored-by: Turbobot <turbobot@vercel.com>
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
Fixes #12554
When
.gitignoreis modified but not yet committed, its ignore patterns are silently dropped during untracked file discovery, causing gitignored paths (likenode_modules/) to leak into task input hashes, which breaks caching.Reason
PR #12339 replaced subprocess-based
git ls-fileswith in-processgix-indexfor file discovery. The newfind_untracked_files()function pre-builds gitignore matchers by scanningls_tree_hashes— the set of clean tracked files whose stat matches the git index. When.gitignoreis dirty (modified on disk), its stat no longer matches the index entry, so it gets classified asModifiedand placed instatus_entriesinstead. The matcher construction loop never looks there, so no ignore rules from that file are applied.The old
git ls-files --others --exclude-standardapproach didn't have this problem because git reads.gitignorefrom the working tree, not from the index.Fix
The gitignore matcher construction now scans both
ls_tree_hashesand non-deleted entries instatus_entriesfor.gitignorefiles. Since the code already reads.gitignorecontent from the filesystem (not from the index), the only change needed was expanding the iteration to include dirty tracked files.Testing
Two regression tests added covering root-level and nested dirty
.gitignorefiles. Both fail before the fix and pass after.