git-crypt
git-crypt copied to clipboard
Keep empty files unencrypted
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
This is being a real nuisance here for me too. What do we need to get this merged?
I rebased this to the latest master
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.
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
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!