git-crypt icon indicating copy to clipboard operation
git-crypt copied to clipboard

Keep empty files unencrypted

Open hugopeixoto opened this issue 6 years ago • 5 comments

To work around the issue that git considers the working directory dirty when empty files are encrypted, these are kept untouched when cleaning/smudging.

Security wise, this is not an issue, as you can check if an encrypted file is empty due to the deterministic encryption properties.

This fixes #53

hugopeixoto avatar Oct 29 '18 19:10 hugopeixoto

This is being a real nuisance here for me too. What do we need to get this merged?

ticklemynausea avatar Nov 30 '18 21:11 ticklemynausea

I rebased this to the latest master

hugopeixoto avatar Jul 13 '20 10:07 hugopeixoto

I agree in principle that this is the correct fix.

Unfortunately, it's a breaking change to git-crypt's on-disk format. Empty files that were previously committed to the repo encrypted will now appear "modified" to Git. I'm not sure if there are other implications.

I think we need to find a way to apply this behavior to new but not existing git-crypt repos.

AGWA avatar Jul 29 '20 00:07 AGWA

I think we can do that by setting a flag during git-crypt init, something like encrypt-empty-files=false which defaults to true if not set, and checking it on clean/smudge filters.

Initially I was thinking of making it a git-config, but the default files are not persisted across clones, so that wouldn't work. Maybe it could be stored in a file in .git-crypt/ and read by git-config --file? That would avoid adding too much parsing code.

Something like:

git config --file .git-crypt/config git-crypt.encrypt-empty-files

hugopeixoto avatar Jul 29 '20 07:07 hugopeixoto

The place to set this is in the key file, which is fortunately extensible. I've implemented this in #210. I would appreciate your testing!

AGWA avatar Jul 29 '20 13:07 AGWA