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

From: James Cherti <[email-masked]>
Date: Tue, 22 Jul 2025 21:47:41 -0400

On 2025-07-22 15:37, Sean Whitton wrote:
> Hello,
> 
> On Tue 22 Jul 2025 at 09:27am -04, James Cherti wrote:
> 
>>> Another problem is that you can't commit changes from *vc-diff* buffers
>>> with --textconv, and if you try to do so anyway, it might break things
>>> in your repository, without you realising.
>>
>> Out of curiosity, how can I reproduce the issue that occurs
>> when committing from a vc-diff buffer with --textconv?
> 
> I believe that if you try to use C-x v v in a diff buffer that's
> textconv'd, it'll try to apply the plain text diff to the binary file.

Thanks for the explanation, Sean.

Just a quick note:
- with --textconv: I tried committing a git-crypt
   encrypted file using C-x v v after viewing its diff, and
   although the operation failed, it didn’t seem to cause any
   actual harm to the repository (with --textconv activated):
     vc-do-command: Failed (status 1): git --no-pager apply
     --cached /tmp/ git-patchncypZR .

- Without --textconv, using C-x v v has no effect, it simply
   displays "No next file" in the minibuffer and does not stage
   or commit the changes.

>>> Therefore I think that users should have to add this to
>>> vc-git-diff-switches themselves if they want this.  I'll revert the
>>> change.
>>
>> If the change is simply reverted, some users may not
>> discover that their issue can be addressed by using the
>> --textconv option.
>>
>> Providing this behavior as an optional, user-configurable
>> variable would make its existence visible through the
>> docstring. This could help reduce confusion and the time
>> users spend investigating why vc-diff appears broken or
>> why tools like diff-hl fail to work correctly in
>> repositories that use git-crypt:
>> https://github.com/dgutov/diff-hl/issues/244#issuecomment-3102297241
> 
> The thing is, you could make an argument like this for all the other
> optional arguments that git-diff{,-index} have.  One point of having
> vc-git-diff-switches is to avoid having a separate Emacs option for each
> individual optional argument.

That's a fair point, I agree that duplicating each Git diff
option into its own Emacs variable would be defeat the purpose
of vc-git-diff-switches.

At least this discussion now exists, so users facing similar
issues are more likely to come across it when searching for
solutions.

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