git patch format with copy/rename + modify, and binary files
From: Brendan Cully <hidden>
Date: 2016-06-15 22:42:36
Subsystem:
the rest · Maintainer:
Linus Torvalds
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?