Skip to content

Negation "!" in .dvcignore doesn't unignore #10122

Open
@Eve-ning

Description

@Eve-ning

Bug Report

Issue name

Negation "!", commonly used in .gitignore to "unignore" files, doesn't work in DVC.

Description

Given 2 files:

  • ignore.txt
  • no-ignore.txt

We can git ignore them using this .gitignore file

ignore.txt
!no-ignore.txt

However, in DVC, it doesn't "unignore".

Reproduce

Output shown in comments

touch ignore.txt no-ignore.txt
echo -e 'ignore.txt\n!no-ignore.txt' > .dvcignore
echo -e 'ignore.txt\n!no-ignore.txt' > .gitignore
cat .dvcignore
# ignore.txt
# !no-ignore.txt
git check-ignore ignore.txt no-ignore.txt
# ignore.txt
dvc check-ignore ignore.txt no-ignore.txt
# ignore.txt
# no-ignore.txt

Expected

Ideally, both check-ignores should be the same

Environment information

Output of dvc doctor:

$ dvc doctor
DVC version: 3.30.1 (pip)
-------------------------
Platform: Python 3.10.12 on Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Subprojects:
        dvc_data = 2.22.0
        dvc_objects = 1.2.0
        dvc_render = 0.6.0
        dvc_task = 0.3.0
        scmrepo = 1.4.1
Supports:
        gs (gcsfs = 2023.10.0),
        http (aiohttp = 3.9.0, aiohttp-retry = 2.8.3),
        https (aiohttp = 3.9.0, aiohttp-retry = 2.8.3)
Config:
        Global: /home/jc/.config/dvc
        System: /etc/xdg/dvc
Cache types: hardlink, symlink
Cache directory: 9p on drvfs
Caches: local
Remotes: gs
Workspace directory: 9p on drvfs
Repo: dvc, git
Repo.site_cache_dir: /var/tmp/dvc/repo/67bc00a31a88271f0f2653ea5494f098

Additional Information (if any):

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDid we break something?gitRelated to git and git backendsp2-mediumMedium priority, should be done, but less important

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions