pre-commit: git apply error when using git-crypt
Hi. I am currently using git-crypt
in tandem with some pre-commit
hooks
Upon adding a new file for encryption --> a corresponding .gitattributes
entry --> git commit -m "blah"
I encounter the following error:
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /Users/bob/.cache/pre-commit/patch1530518673.
Trim Trailing Whitespace.................................................Passed
Check Yaml...............................................................Passed
Fix End of Files.........................................................Passed
Ansible-lint.............................................................Passed
[WARNING] Stashed changes conflicted with hook auto-fixes... Rolling back fixes...
An unexpected error has occurred: CalledProcessError: Command: ('/usr/local/Cellar/git/2.18.0/libexec/git-core/git', '-c', 'core.autocrlf=false', 'apply', '--whitespace=nowarn', '/Users/bob/.cache/pre-commit/patch1530518673')
Return code: 128
Expected return code: 0
Output: (none)
Errors:
error: unrecognized input
git version: 2.18.0
pre-commit version: 1.10.2
.pre-commit-config.yaml
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v1.3.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: end-of-file-fixer
- repo: https://github.com/willthames/ansible-lint.git
rev: v3.4.23
hooks:
- id: ansible-lint
entry: ansible-lint bootstrap.yml
.gitattributes:
hosts/testing/secret-vars.yml filter=git-crypt diff=git-crypt
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 3
- Comments: 15 (9 by maintainers)
I submitted a more thorough investigation to the git mailing list – https://marc.info/?l=git&m=166733577332408&w=2
I can confirm that this issue was resolved for me by making sure I wasn’t staging empty files that matched my
.gitattributes
git-crypt smudge/filter settings.Hi! I’ve got the same issue:
.pre-commit-config.yml
it solved for me
as it turned out there were a couple of empty files. I took a look inside /Users/yulia/.cache/pre-commit/pre-commit.log and noticed that 1 commit ago I committed 2 totally empty secrets files. So I filled them in. then
yeah 😢 that’s why I haven’t dug into it yet beyond the repro above
I started looking into this from the
git
side but never got a definitive response – it comes down to unstaged things in a smudge filter generating bogusgit diff
that cannot be latergit apply
dthe current known workaround is to make sure such files are
git add
ed before committing, but isn’t idealI’m not sure what it would take to fix this, I suspect a fix from
git
is necessary (or some workaround wherepre-commit
identifies smudge-filter files and handles them separately)Wondering if there was an update on this issue? If there are any hints on what the issue might be, I’d be keen to offer help fixing - it’s something we run into frequently
hmm, my crash is actually different from yours – I wonder there’s two issues here :S