twpayne / chezmoi

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

chezmoi data returns strange chezmoi.config.diff.pager #3590

Closed ErrrorMaxx closed 8 months ago

ErrrorMaxx commented 8 months ago

Describe the bug

chezmoi data (and probably {{ .chezmoi.config.diff.pager }} template) returns strange .chezmoi.config.diff.pager when it is not set in config file

To reproduce

cz data | gojq '.chezmoi.config.diff.pager' or cz data | jq '.chezmoi.config.diff.pager' or cz data | grep pager When diff.pager is not set in config file

Expected behavior

When pager is not set in config file chezmoi data should return "", not "\u0000" for .chezmoi.config.diff.pager

Output of command with the --verbose flag

$ chezmoi --verbose data
{
  "chezmoi": {
    ...
    "config": {
      ...
      "diff": {
        "args": null,
        "command": "",
        "exclude": [],
        "pager": "\u0000",
        "reverse": false,
        "scriptContents": true
      },
      ...
    },
    ...
  },
  ...
}

Output of chezmoi doctor

```console $ chezmoi doctor RESULT CHECK MESSAGE warning version v2.46.1 ok latest-version v2.46.1 ok os-arch android/arm64 ok uname Linux localhost 4.19.191+ #1 SMP PREEMPT Wed Nov 29 21:44:22 CST 2023 aarch64 Android ok go-version go1.21.6 (gc) ok executable /data/data/com.termux/files/usr/bin/chezmoi ok config-file ~/.config/chezmoi/chezmoi.yaml, last modified 2024-02-22T13:25:03Z ok source-dir /sdcard/.dots is a git working tree (clean) ok suspicious-entries no suspicious entries ok working-tree /sdcard/.dots is a git working tree (clean) ok dest-dir ~ is a directory warning umask 077 ok cd-command found /data/data/com.termux/files/usr/bin/zsh ok cd-args /data/data/com.termux/files/usr/bin/zsh info diff-command not set ok edit-command found /data/data/com.termux/files/usr/bin/micro ok edit-args /data/data/com.termux/files/usr/bin/micro ok git-command found /data/data/com.termux/files/usr/bin/git, version 2.43.2 warning merge-command vimdiff not found in $PATH ok shell-command found /data/data/com.termux/files/usr/bin/zsh ok shell-args /data/data/com.termux/files/usr/bin/zsh info age-command age not found in $PATH ok gpg-command found /data/data/com.termux/files/usr/bin/gpg2, version 2.4.4 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw not found in $PATH info bitwarden-secrets-command bws not found in $PATH info dashlane-command dcli not found in $PATH info doppler-command doppler not found in $PATH info gopass-command gopass not found in $PATH info keepassxc-command keepassxc-cli not found in $PATH info keepassxc-db not set info keeper-command keeper not found in $PATH info lastpass-command lpass not found in $PATH info pass-command pass not found in $PATH info passhole-command ph not found in $PATH info rbw-command rbw not found in $PATH info vault-command vault not found in $PATH info vlt-command vlt not found in $PATH info secret-command not set ```
twpayne commented 8 months ago

Thanks for spotting this!

For background info, chezmoi needs to distinguish between diff.pager being set to the empty string in the user's config file (which means disable the diff pager) and diff.pager not being set (which means use the default diff pager). For this, chezmoi sets diff.pager to a sentinel value ("\u0000") by default, so it can tell if the user set diff.pager or not in their config file. This sentinel value was leaking into the output of chezmoi data.

3592 fixes this.