Skip to content
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

chezmoiignore: deeply nested single file exclude generates warnings that parents are ignored #3097

Open
eugenesvk opened this issue Jul 17, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@eugenesvk
Copy link
Contributor

eugenesvk commented Jul 17, 2023

Is your feature request related to a problem? Please describe.

I have a folder with a bunch of subfolders I'd like to ignore. But then deeply nested there is a single file that I'd like to track. However, trying to exclude that file from chezmoiignore. But then I get a bunch of warnings about ignored parents

↓ example folder structure

~/zzz           	# ← ignore
~/zzz/a         	# ← ignore
~/zzz/a-child   	# ← ignore
~/zzz/a/b       	# ← ignore
~/zzz/a/b-child 	# ← ignore
~/zzz/a/b/in.txt	# ← I only want this file

Describe the solution you'd like

Since per doc

All excludes take priority over all includes

I'd like that to be true also for intermediate subfolders in path

So this should work

   zzz/*
  !zzz/a/b/in.txt	#     except for ← file

but instead I get on chezmoi add ~/zzz/a/b/in.txt

# chezmoi: warning: ignoring zzz/a
# chezmoi: /Users/eugenesv/zzz/a/b: parent directory not in source state

or this

   zzz/**
  !zzz/a/b/in.txt	#     except for ← file

then the warnings are:

# chezmoi: warning: ignoring zzz
# chezmoi: warning: ignoring zzz/a
# chezmoi: warning: ignoring zzz/a/b
# chezmoi: warning: ignoring zzz/a/b/in.txt

Describe alternatives you've considered

I'm currently doing this tedious exercise in .chezmoiignore

   zzz/*         	# subfolders in zzz
  !zzz/a         	# ... except for ← subfolder
   zzz/a/*       	# all files in   ← subfolder
  !zzz/a/b       	#     except for ← subfolder
   zzz/a/b/*     	# all files in   ← subfolder
  !zzz/a/b/in.txt	#     except for ← file

Additional context

Filing as a follow-up to this discussion #2852 (reply in thread)

@eugenesvk eugenesvk added the enhancement New feature or request label Jul 17, 2023
@halostatue
Copy link
Collaborator

Thanks. I’ve edited your comment to properly refer to chezmoiignore instead of gitignore; I personally think that this is a bug, but as it may be an incomplete specification of expectations, enhancement is good enough for now.

@twpayne I’ll probably have time to look at this in a day or two if you don’t get to it before then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants