chezmoi icon indicating copy to clipboard operation
chezmoi copied to clipboard

Not all diffs shown when using an external diff command

Open twpayne opened this issue 2 years ago • 1 comments

Describe the bug

@k4leg reports a number of problems when using an external diff command in #2097. It turns out that there are at least the following problems:

  • Scripts that will be run are not shown when using an external diff command.
  • The diff.include and diff.exclude configuration variables are not respected when using an external diff command.

To reproduce

  1. Create a run_ script that should run every time.
  2. Configure a trivial external diff command, e.g. echo or cat.
  3. Run chezmoi diff.
  4. Observer that the scripts contents are not printed.

Expected behavior

Scripts contents are printed by chezmoi diff when an external diff command is used.

Output of command with the --verbose flag

n/a

Output of chezmoi doctor

$ chezmoi doctor
RESULT   CHECK                MESSAGE
ok       version              v2.17.1, commit 565cbbe117746aa6bfec5f2cee20ae4cbbb5e645, built at 2022-05-30T08:06:04Z, built by Homebrew
ok       latest-version       v2.17.1
ok       os-arch              darwin/arm64
ok       uname                Darwin Toms-Air 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64
ok       go-version           go1.18.2 (gc)
ok       executable           /opt/homebrew/bin/chezmoi
ok       upgrade-method       brew-upgrade
ok       config-file          ~/.config/chezmoi/chezmoi.toml
ok       source-dir           ~/.local/share/chezmoi is a directory
ok       suspicious-entries   no suspicious entries
ok       working-tree         ~/.local/share/chezmoi is a directory
ok       dest-dir             ~ is a directory
ok       shell-command        found /bin/zsh
ok       shell-args           /bin/zsh
ok       cd-command           found /bin/zsh
ok       cd-args              /bin/zsh
ok       edit-command         found /opt/homebrew/bin/vim
ok       edit-args            /opt/homebrew/bin/vim
ok       diff-command         found /bin/cat
ok       umask                022
ok       git-command          found /opt/homebrew/bin/git, version 2.36.1
ok       merge-command        found /opt/homebrew/bin/vimdiff
ok       age-command          found /opt/homebrew/bin/age, version 1.0.0
ok       gpg-command          found /opt/homebrew/bin/gpg, version 2.3.6
info     pinentry-command     not set
ok       1password-command    found /usr/local/bin/op, version 2.4.0
ok       bitwarden-command    found /opt/homebrew/bin/bw, version 1.22.1
ok       gopass-command       found /opt/homebrew/bin/gopass, version 1.14.3
ok       keepassxc-command    found /opt/homebrew/bin/keepassxc-cli, version 2.7.1
ok       keeper-command       found /opt/homebrew/bin/keeper, version 16.6.4
info     keepassxc-db         not set
ok       lastpass-command     found /opt/homebrew/bin/lpass, version 1.3.3
ok       pass-command         found /opt/homebrew/bin/pass, version 1.7.4
ok       vault-command        found /opt/homebrew/bin/vault, version 1.10.1
info     secret-command       not set```

</details>

## Additional context

Add any other context about the problem here.

twpayne avatar Jun 05 '22 21:06 twpayne

Also, #2116 should be supported for external diff commands.

twpayne avatar Jun 06 '22 00:06 twpayne

Sorry @twpayne , I had some issue related to custom diff too. I don't know if I should open new issue, so I just linked it here. Here's the detail. https://github.com/dandavison/delta/issues/1162

Let me know if you need more detail.

latipun7 avatar Aug 18 '22 07:08 latipun7

I happened to be working on this issue yesterday evening and this morning.

#2265 should fix the immediate problems. There are still some corner cases where external diff commands will behave differently from the builtin diff (e.g. when only file modes change, or when creating symlinks) but it should be better now.

twpayne avatar Aug 18 '22 09:08 twpayne