@matheusbsbs / matheus-bagliano / commits / 2b6eef943f
Fork 0

Make apply --binary a no-op.

Historically we did not allow binary patch applied without an explicit permission from the user, and this flag was the way to do so. This makes the flag a no-op by always allowing binary patch application. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Sep 6, 2006 at 22:45 UTC 2b6eef943ff81df63a809857b7b400ee175eb29b
3 files changed +11 -25
Documentation/git-apply.txt
+4 -9
@@ -110,15 +110,10 @@ OPTIONS
110 deletion part but not addition part.
111
112 --allow-binary-replacement, --binary::
113 - When applying a patch, which is a git-enhanced patch
114 - that was prepared to record the pre- and post-image object
115 - name in full, and the path being patched exactly matches
116 - the object the patch applies to (i.e. "index" line's
117 - pre-image object name is what is in the working tree),
118 - and the post-image object is available in the object
119 - database, use the post-image object as the patch
120 - result. This allows binary files to be patched in a
121 - very limited way.
113 + Historically we did not allow binary patch applied
114 + without an explicit permission from the user, and this
115 + flag was the way to do so. Currently we always allow binary
116 + patch application, so this is a no-op.
117
118 --exclude=<path-pattern>::
119 Don't apply changes to files matching the given path pattern. This can
builtin-apply.c
+5 -14
@@ -28,7 +28,6 @@ static int prefix_length = -1;
28 static int newfd = -1;
29
30 static int p_value = 1;
31 -static int allow_binary_replacement;
31 static int check_index;
32 static int write_index;
33 static int cached;
@@ -1228,14 +1227,12 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
1227 }
1228 }
1229
1231 - /* Empty patch cannot be applied if:
1232 - * - it is a binary patch and we do not do binary_replace, or
1233 - * - text patch without metadata change
1230 + /* Empty patch cannot be applied if it is a text patch
1231 + * without metadata change. A binary patch appears
1232 + * empty to us here.
1233 */
1234 if ((apply || check) &&
1236 - (patch->is_binary
1237 - ? !allow_binary_replacement
1238 - : !metadata_changes(patch)))
1235 + (!patch->is_binary && !metadata_changes(patch)))
1236 die("patch with only garbage at line %d", linenr);
1237 }
1238
@@ -1676,11 +1673,6 @@ static int apply_binary(struct buffer_desc *desc, struct patch *patch)
1673 unsigned char hdr[50];
1674 int hdrlen;
1675
1679 - if (!allow_binary_replacement)
1680 - return error("cannot apply binary patch to '%s' "
1681 - "without --allow-binary-replacement",
1682 - name);
1683 -
1676 /* For safety, we require patch index line to contain
1677 * full 40-byte textual SHA1 for old and new, at least for now.
1678 */
@@ -2497,8 +2489,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
2489 }
2490 if (!strcmp(arg, "--allow-binary-replacement") ||
2491 !strcmp(arg, "--binary")) {
2500 - allow_binary_replacement = 1;
2501 - continue;
2492 + continue; /* now no-op */
2493 }
2494 if (!strcmp(arg, "--numstat")) {
2495 apply = 0;
t/t4103-apply-binary.sh
+2 -2
@@ -94,11 +94,11 @@ test_expect_failure 'apply binary diff (copy) -- should fail.' \
94 'do_reset
95 git-apply --index C.diff'
96
97 -test_expect_failure 'apply binary diff without replacement -- should fail.' \
97 +test_expect_success 'apply binary diff without replacement.' \
98 'do_reset
99 git-apply BF.diff'
100
101 -test_expect_failure 'apply binary diff without replacement (copy) -- should fail.' \
101 +test_expect_success 'apply binary diff without replacement (copy).' \
102 'do_reset
103 git-apply CF.diff'
104