Skip to content

Add negation to merge files, adds CACHEDIR.TAG support #757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kaspar030
Copy link

@kaspar030 kaspar030 commented Apr 27, 2025

This PR makes the previously forbidden ! modifier available to merge and dir-merge filters.
It's effect is that it turns the default for that filter file to - /** (which is added after the merge file rules).

Additionally, unless the e modifier is also set, another rule for including the rules file is added.

This by itself makes it possible to honour CACHEDIR.TAG files by specifying --filter='dir-merge,+! CACHEDIR.TAG'. The CACHEDIR.TAG is still parsed. Its first line is usually Signature: 8a477f597d28d172789f06886806bc55, so currently a rule for that is added, but it would in practice never(tm) match.

I could imagine adding another modifier specifying a merge file is just a tag, meaning it is not parsed at all. Maybe t. Or, special-case the CACHEDIR.TAG filename. Or, ignore all rules with the exact content Signature: 8a477f597d28d172789f06886806bc55. But also this is already very usable as is, and IMO a pretty small change.

Additionally it would be easy to add aliases like tar and others have them:

       --exclude-caches
              Exclude contents of directories containing file CACHEDIR.TAG,
              except for the tag file itself. -> --filter='dir-merge,+! CACHEDIR.TAG'

       --exclude-caches-all
              Exclude directories containing file CACHEDIR.TAG and the file
              itself. -> --filter='dir-merge,+e! CACHEDIR.TAG'

       --exclude-caches-under
              Exclude everything under directories containing CACHEDIR.TAG

Let me know what you think!

Implements #451, #499.
For reference, the CACHEDIR.TAG spec: https://bford.info/cachedir/

Signed-off-by: Kaspar Schleiser <[email protected]>
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.

None yet

1 participant