twpayne / chezmoi

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

calling `chezmoi merge` on an encrypted file shows pgp message #564

Closed fbartels closed 3 years ago

fbartels commented 4 years ago

Describe the bug Having an encrypted file the chezmoi dir and modifying it locally with the intent of calling chezmoi merge $filename afterwards results in the crypt text being shown in the diff and not the plain version.

To reproduce

chezmoi add --encrypt file
nano file
chezmoi merge file

Expected behavior The file should be encrypted before presenting it in the merge via (chezmoi diff shows decrypted version).

Output of command with --verbose

$ chezmoi merge --verbose --debug .netrc
3 files to edit
2020/01/13 17:04:55 Run("/usr/bin/vimdiff /home/fbartels/.netrc /home/fbartels/.local/share/chezmoi/encrypted_private_dot_netrc /tmp/chezmoi366635937/.netrc") (2m46.753657707s)
/usr/bin/vimdiff /home/fbartels/.netrc /home/fbartels/.local/share/chezmoi/encrypted_private_dot_netrc /tmp/chezmoi366635937/.netrc

Output of chezmoi doctor

$ chezmoi doctor
     ok: version 1.7.11, commit acf34783a82ef39a2bd4794126342764aa800ad7, built at 2020-01-09T01:01:31Z
     ok: runtime.GOOS linux, runtime.GOARCH amd64
     ok: /home/fbartels/.local/share/chezmoi (source directory, perm 700)
     ok: /home/fbartels (destination directory, perm 750)
     ok: /home/fbartels/.config/chezmoi/chezmoi.toml (configuration file)
     ok: /bin/bash (shell)
     ok: /bin/nano (editor)
     ok: /usr/bin/vimdiff (merge command)
     ok: /usr/bin/git (source VCS command, version 2.17.1)
     ok: /usr/bin/gpg (GnuPG, version 2.2.4)
warning: op (1Password CLI, not found)
warning: bw (Bitwarden CLI, not found)
warning: gopass (gopass CLI, not found)
warning: keepassxc-cli (KeePassXC CLI, not found)
warning: lpass (LastPass CLI, not found)
warning: pass (pass CLI, not found)
warning: vault (Vault CLI, not found)

Additional context I have not reproduced it yet, but it also seems that chezmoi merge ignores templated files (would store the file as it is locally discarding templated syntax).

twpayne commented 4 years ago

Great catch! It's certainly case that chezmoi merge also ignores templated files.