Skip to content

Comments

Fix: dvc status works with ** globbing patterns in .gitignore#11002

Closed
paipeline wants to merge 3 commits intotreeverse:mainfrom
paipeline:fix/gitignore-globbing-patterns-10987
Closed

Fix: dvc status works with ** globbing patterns in .gitignore#11002
paipeline wants to merge 3 commits intotreeverse:mainfrom
paipeline:fix/gitignore-globbing-patterns-10987

Conversation

@paipeline
Copy link

Summary

Fixes issue #10987: dvc status reports "no data tracked" when using ** globbing patterns in .gitignore with negations.

Problem

When using complex .gitignore patterns like:

  • data/raw/**
  • !data/raw/**/*.dvc

DVC's collect_files() function incorrectly determined that .dvc files were ignored, causing dvc status to report "There are no data or pipelines tracked in this project yet." even though .dvc files existed and were committed to git.

Root Cause

The collect_files() function was using Git's scm.is_ignored() for all files, including .dvc files. Git's ignore system has different behavior for complex ** patterns with negations compared to DVC's ignore system.

Solution

Modified is_ignored() function in dvc/repo/index.py to:

  • Use DVC's own dvcignore.is_ignored_file() for .dvc files
  • Continue using Git's scm.is_ignored() for other files

This ensures .dvc files are correctly recognized even when they're in directories ignored by ** patterns.

Changes

  • Fixed is_ignored() function to use appropriate ignore system based on file type
  • Added comprehensive test coverage for various ** globbing scenarios
  • Maintains full backward compatibility for existing ignore behavior
  • Added verification script to demonstrate the fix

Testing

  • Reproduces original issue scenario
  • Tests complex nested ** patterns with negations
  • Verifies both specific and globbing pattern behaviors
  • Validates collect_files() function directly
  • All existing functionality preserved

Impact

  • Critical fix for users with complex gitignore patterns using ** globbing
  • Zero breaking changes - improves existing behavior without affecting other use cases
  • Production-ready - resolves silent failure mode affecting dvc status and dvc push

Closes #10987

paipeline and others added 3 commits February 24, 2026 13:33
Fixes issue treeverse#10987: dvc status reports 'no data tracked' when using
** globbing patterns in .gitignore with negations.

Root cause: collect_files() was using Git's scm.is_ignored() for all
files including .dvc files. Git's ignore system has different behavior
for complex ** patterns with negations compared to DVC's ignore system.

Solution: Use DVC's own dvcignore.is_ignored_file() for .dvc files,
which properly handles ** globbing patterns with negations like:
- data/raw/**         (ignore everything)
- !data/raw/**/*.dvc  (except .dvc files)

This ensures .dvc files are correctly recognized even when they're in
directories that are ignored by ** patterns.

Changes:
- Modified is_ignored() in dvc/repo/index.py to use DVC's ignore
  system for .dvc files and Git's system for other files
- Added comprehensive test coverage for various ** globbing scenarios
- Maintains backward compatibility for all existing ignore behavior
@github-project-automation github-project-automation bot moved this to Backlog in DVC Feb 24, 2026
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


paipeline seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@paipeline
Copy link
Author

Auto-closed, finding correct repo

@paipeline paipeline closed this Feb 24, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in DVC Feb 24, 2026
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.

dvc status: reports "no data tracked" when using ** globbing patterns in .gitignore

2 participants