Re: Why is there a --binary option needed for git-apply?
From: Shawn Pearce <hidden>
Date: 2016-06-15 22:42:39
Carl Worth [off-list ref] wrote:
Shawn Pearce was kind enough to direct me to the --binary option for git-apply which solved my problem. But that left me wondering why git-apply requires this extra command-line option to do its job. Shouldn't git-apply simply apply the patch it is given? If there is some reason for git-apply to only apply binary patches when under the duress of --binary, then at the very least it could use a better error message explaining the situation.
I see no reason why git-apply shouldn't always have --binary enabled. If the patch contains full pre-image/post-image blob IDs and we have an exact match against the pre-image and we have the post-image in our tree it should just apply even if the user didn't supply --binary. If the patch contains a binary delta and we have an exact match against the pre-image it should also just apply. But if there's a binary hunk and we lack the full pre/post image blob IDs, we lack the post image and there's no detla, or the pre-image doesn't exactly match then we should obviously still abort with a reasonable error message as there's no sane course of action to take. -- Shawn.