AGWA / git-crypt

Transparent file encryption in git
https://www.agwa.name/projects/git-crypt/
GNU General Public License v3.0
8.18k stars 475 forks source link

Keep empty files unencrypted #162

Open hugopeixoto opened 5 years ago

hugopeixoto commented 5 years ago

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

ticklemynausea commented 5 years ago

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

hugopeixoto commented 4 years ago

I rebased this to the latest master

AGWA commented 4 years ago

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.

hugopeixoto commented 4 years ago

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
AGWA commented 4 years ago

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!