# git patch format with copy/rename + modify, and binary files

1 messages from 2006-08-11 to 2006-08-11. Participants: Brendan Cully.
Thread: https://gitlist.dev/t/5213

## Brendan Cully, 2006-08-11 20:50

Subject: git patch format with copy/rename + modify, and binary files
Message-ID: <20060811205022.GA13521@xanadu.kublai.com>
URL: https://gitlist.dev/e/20060811205022.GA13521%40xanadu.kublai.com

```
Hi,

While working on an external git patch importer, I noticed that git
patches can break silently when fed to vanilla patch. Take this hunk
from the git tree:

diff --git a/git-pull-script b/git-fetch-script   
similarity index 89%
copy from git-pull-script
copy to git-fetch-script
index bd892c7..17f22af 100755
--- a/git-pull-script
+++ b/git-fetch-script
@@ -39,8 +39,3 @@ download_one "$merge_repo/$merge_name" "

 echo "Getting object database"
 download_objects "$merge_repo" "$(cat "$GIT_DIR"/MERGE_HEAD)"
-
-git-resolve-script \
-       "$(cat "$GIT_DIR"/HEAD)" \
-       "$(cat "$GIT_DIR"/MERGE_HEAD)" \
-       "$merge_repo"

git-apply would presumably create git-fetch-script by copying
git-pull-script then deleting this hunk. Vanilla patch simply deletes
the hunk from git-pull-script. This seems bad. Is there any reason why
git diff shouldn't use

--- a/git-fetch-script
+++ b/git-fetch-script

instead?

On a related note, it'd be nice if the format allowed for some kind of
representation of binary data. I had a half-baked idea that it could
hold a line describing the encoding of the diff, eg

encoding base64

which could indicate that the diff should be decoded as base64 before
being applied. This could allow a patch to hold a binary file add, or
wrap a binary diff, though it doesn't specify what form such a diff
should take...

thoughts?

```
