twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.85k stars 477 forks source link

`diff.exclude: dirs` not respected when removing directories #2573

Closed latipun7 closed 1 year ago

latipun7 commented 1 year ago

Describe the bug

I have this following config in ~/.config/chezmoi/config.yaml:

diff:
   pager: delta
   command: delta
   args: ["--paging", "never"]
   exclude: [dirs, scripts]

Whenever I add empty directories, and I run chezmoi apply --verbose, chezmoi successfully ignoring giving diff for that directory so custom diff command like delta not error when trying to diff directories.

But, when I tried to remove file along with directory in the exact_dirs, then chezmoi giving error when I run chezmoi apply --verbose.

To reproduce

Expected behavior

diff.exclude: dirs also respected when trying to remove directories

Output of command with the --verbose --debug flag

$ chezmoi apply --verbose ~/.config/lvim --debug

2022-11-16T17:35:45+07:00 INF defaultPreApplyFunc actualEntryState={"ContentsSHA256":"64d59030d37cc292f918c941ba2e940c525122e2869fd4ba24a97fdba82633c9","Mode":420,"Type":"file","contents":"local surr_utils = require(\"nvim-surround.config\")\nlocal ts_util..."} lastWrittenEntryState={"ContentsSHA256":"64d59030d37cc292f918c941ba2e940c525122e2869fd4ba24a97fdba82633c9","Mode":420,"Type":"file"} targetEntryState={"ContentsSHA256":"64d59030d37cc292f918c941ba2e940c525122e2869fd4ba24a97fdba82633c9","Mode":420,"Type":"file","contents":"local surr_utils = require(\"nvim-surround.config\")\nlocal ts_util..."} targetRelPath=.config/lvim/after/ftplugin/markdown.lua
2022-11-16T17:35:45+07:00 INF Lstat component=system name=/home/latipun/.config/lvim/after/plugin
2022-11-16T17:35:45+07:00 INF Get bucket=entryState component=persistentState key=/home/latipun/.config/lvim/after/plugin value="{\n  \"type\": \"dir\",\n  \"mode\": 2147484141\n}\n"
2022-11-16T17:35:45+07:00 INF defaultPreApplyFunc actualEntryState={"ContentsSHA256":"","Mode":2147484141,"Type":"dir"} lastWrittenEntryState={"ContentsSHA256":"","Mode":2147484141,"Type":"dir"} targetEntryState={"ContentsSHA256":"","Mode":0,"Type":"remove"} targetRelPath=.config/lvim/after/plugin
error: Could not access '/home/latipun/.config/lvim/after/plugin/null'
2022-11-16T17:35:45+07:00 ERR Run error="exit status 1" args=["delta","--paging","never","/home/latipun/.config/lvim/after/plugin","/dev/null"] duration=43.041842ms exitCode=1 path=/usr/bin/delta systemTime=12.553 userTime=35.857
2022-11-16T17:35:45+07:00 ERR ReadFile error="read /home/latipun/.config/lvim/after/plugin: is a directory" component=system data= name=/home/latipun/.config/lvim/after/plugin size=0
chezmoi: exit status 1; read /home/latipun/.config/lvim/after/plugin: is a directory
twpayne commented 1 year ago

Thank you very much for spotting and reporting this. #2592 should fix it.