From: Anthony Sottile Date: Tue, 01 Nov 2022 20:55:42 GMT Subject: smudge filters do not round trip through `git diff` / `git apply` Message-ID: this is boiled down from a larger problem outlined here: https://github.com/pre-commit/pre-commit/issues/776 I've had some time to sit down and poke at this today -- here's my minimal reproduction using just `git` and `git-crypt` -- though my users have reported this also seems to affect other smudge filters. I understand `git-crypt` is not associated with the git project, however it was an easy, readily-available smudge filter to demonstrate the problem. I'm using git-crypt 0.6.0 (from ubuntu 22.04). (the key material below is not sensitive -- I generated it afresh in a docker container) ```bash #!/usr/bin/env bash set -euxo pipefail rm -rf repo git --version git init --quiet repo -b main cd repo git commit --allow-empty -m 'Initial empty commit' # determinstic git-crypt key so the output is stable base64 -d > keyfile < .gitattributes git add .gitattributes echo 'hello world' > f git add f rm f && touch f tree="$(git write-tree)" ! git diff-index \ --ignore-submodules \ --binary \ --exit-code \ --no-color \ --no-ext-diff \ --no-textconv \ "$tree" -- > patch git checkout -- . git apply patch || (echo FAILED && cat patch && exit 1) ``` here's my output: ```console $ bash t.sh + rm -rf repo + git --version git version 2.38.1.381.gc03801e19c + git init --quiet repo -b main + cd repo + git commit --allow-empty -m 'Initial empty commit' [main (root-commit) 97d9520] Initial empty commit + base64 -d + git-crypt unlock keyfile + echo 'f filter=git-crypt diff=git-crypt' + git add .gitattributes + echo 'hello world' + git add f + rm f + touch f ++ git write-tree + tree=beca08f8b3c0774060f3e28e081ac69a80a1a10d + git diff-index --ignore-submodules --binary --exit-code --no-color --no-ext-diff --no-textconv beca08f8b3c0774060f3e28e081ac69a80a1a10d -- + git checkout -- . + git apply patch error: binary patch to 'f' creates incorrect result (expecting 2f89279ce748725a41cec60d5025b22efc863b42, got e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) error: f: patch does not apply + echo FAILED FAILED + cat patch diff --git a/f b/f index ee7d1b67cd31482ae9bc772a0b2d016c81e1c613..2f89279ce748725a41cec60d5025b22efc863b42 100644 GIT binary patch literal 0 HcmV?d00001 literal 34 qcmZQ@_Y83kiVO&0IB9<_f2(d}=e+;CXFaaIzZ@c>%yE8!