Show diff of encrypted files in git #3887
Replies: 2 comments 1 reply
-
Not as far as I know. Note that you can clean up temporary file usage through process substitution. This particular case is NOT tested as I don't use encrypted files, but I’ve written many scripts like this before: #!/usr/bin/env bash
set -euo pipefail
if (($# < 1)); then
echo "usage: $(basename "$0") file..."
exit 1
fi
warnings=false
for file in "$@"; do
absolute="$(readlink -f "$file")"
relative="$(git ls-files --full-name "$absolute")"
if [[ -z "$relative" ]]; then
echo >&2 "Error: file '$file' not tracked by git"
warnings=true
continue
fi
git diff --no-index <(git show "HEAD:$relative" | chezmoi decrypt) <(chezmoi decrypt "$absolute")
done
"$warnings" && exit 1 If you wanted to use Fish instead, it would be |
Beta Was this translation helpful? Give feedback.
-
This is a bug in chezmoi. If there are no changes to the plaintext, then chezmoi should not re-encrypt the plaintext.
Yes, |
Beta Was this translation helpful? Give feedback.
-
Many of the files I manage with chezmoi are encrypted (for example files in ~/.ssh). When I make changes with
chezmoi edit
, even if I change nothing in the plaintext, I will end up with a completely changed file in git, because the cypher text changes with every edit even if the edit changes nothing. When I usechezmoi cd
and do agit diff
I obviously cannot tell what has actually changed in these files, if anything. I am just shown two totally different cypher texts. Is there any existing command within chezmoi which allows me to see these changes? I have not found anything.I wrote a script that allows me to see the changes:
I can call this script with
./unecrypted_diff.sh <file>.age
and I get an approximate equivalent togit diff
Does anything in chezmoi do something like this script?
Beta Was this translation helpful? Give feedback.
All reactions