Subject: bug#79050: vc-git incorrectly treats git-crypt encrypted files as binary, even when unlocked

From: James Cherti <[email-masked]>
Date: Sat, 19 Jul 2025 13:59:40 -0400

When using vc-diff in a Git repository where all files are
encrypted with git-crypt https://github.com/AGWA/git-crypt
the output does not reflect actual changes. Modified files
appear unaltered, regardless of edits made. (vc-diff appears
to compare the encrypted binary representations of the files,
rather than their decrypted contents.)

It appears that vc-diff does not take .gitattributes into
account, even though Git itself uses it to determine how to
handle diff filters. As a result, while git diff correctly
shows textual diffs for git-crypt encrypted files (once the
repository is unlocked), Emacs vc-diff treats them as binary
and fails to display the actual changes.

Instead of showing a textual diff, vc-diff reports:
   diff --git a/file b/file
   index a134576..8b24729 100644
   Binary files a/file and b/file differ

Steps to Reproduce:
-------------------
1. Initialize a Git repository and enable git-crypt.
      Create the repo:
      ----------------
      mkdir -p repo
      cd repo
      git init
      git-crypt init
      echo test > README.md

      Create the .gitattributes file:
      -------------------------------
      ** filter=git-crypt diff=git-crypt
      .gitattributes !filter !diff

      Commit:
      -------
      git add .
      git commit -m 'Init'
2. Open the README.md file in Emacs and modify it.
3. Run: M-x vc-diff

Expected Behavior
-----------------
vc-diff should display a textual diff showing the modified lines.

Actual Behavior
---------------
vc-diff reports the file as a binary difference with no
line-level changes, even though the repository is unlocked
and git diff in the terminal shows the correct diff.

Environment:
------------
- Emacs version: 31 (3b2bfdfef63f051a36f4043c32596458ccae605f)
                  2025-07-19 13:05:05 +0300
- OS: Arch Linux

--
James Cherti
GitHub: https://github.com/jamescherti
Website: https://www.jamescherti.com/