git-am: --binary; document --resume and --binary.
Now git-apply can grok binary replacement patches, give --binary flag to git-am. As a safety measure, this is not by default enabled, so that you do not let malicious e-mailed patch to replace an arbitrary path with just a couple of lines (diff index lines, the filename and string "Binary files "...) by accident. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 16, 2005 at 16:46 UTC
087b6742fcab74f7a53626b98969bed27d288e2b
2 files changed
+30
-14
Documentation/git-am.txt
+16
-8
@@ -8,8 +8,8 @@ git-am - Apply a series of patches in a mailbox
8
9
SYNOPSIS
10
--------
11
-'git-am' [--signoff] [--dotest=<dir>] [--utf8] [--3way] <mbox>...
12
-'git-am' [--skip]
11
+'git-am' [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>...
12
+'git-am' [--skip | --resolved]
13
14
DESCRIPTION
15
-----------
@@ -31,6 +31,10 @@ OPTIONS
31
Pass `--utf8` and `--keep` flags to `git-mailinfo` (see
32
gitlink:git-mailinfo[1]).
33
34
+--binary::
35
+ Pass `--allow-binary-replacement` flag to `git-apply`
36
+ (see gitlink:git-apply[1]).
37
+
38
--3way::
39
When the patch does not apply cleanly, fall back on
40
3-way merge, if the patch records the identity of blobs
@@ -44,6 +48,13 @@ OPTIONS
48
--interactive::
49
Run interactively, just like git-applymbox.
50
51
+--resolved::
52
+ After a patch failure (e.g. attempting to apply
53
+ conflicting patch), the user has applied it by hand and
54
+ the index file stores the result of the application.
55
+ Make a commit using the authorship and commit log
56
+ extracted from the e-mail message and the current index
57
+ file, and continue.
58
59
DISCUSSION
60
----------
@@ -56,12 +67,9 @@ recover from this in one of two ways:
67
. skip the current one by re-running the command with '--skip'
68
option.
69
59
-. hand resolve the conflict in the working directory, run 'git
60
- diff HEAD' to extract the merge result into a patch form and
61
- replacing the patch in .dotest/patch file. After doing this,
62
- run `git-reset --hard HEAD` to bring the working tree to the
63
- state before half-applying the patch, then re-run the command
64
- without any options.
70
+. hand resolve the conflict in the working directory, and update
71
+ the index file to bring it in a state that the patch should
72
+ have produced. Then run the command with '--resume' option.
73
74
The command refuses to process new mailboxes while `.dotest`
75
directory exists, so if you decide to start over from scratch,
git-am.sh
+14
-6
@@ -4,7 +4,7 @@
4
. git-sh-setup || die "Not a git archive"
5
6
usage () {
7
- echo >&2 "usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--3way] <mbox>"
7
+ echo >&2 "usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>"
8
echo >&2 " or, when resuming"
9
echo >&2 " $0 [--skip | --resolved]"
10
exit 1;
@@ -40,7 +40,7 @@ fall_back_3way () {
40
cd "$dotest/patch-merge-tmp-dir" &&
41
GIT_INDEX_FILE="../patch-merge-tmp-index" \
42
GIT_OBJECT_DIRECTORY="$O_OBJECT" \
43
- git-apply --index <../patch
43
+ git-apply $binary --index <../patch
44
)
45
then
46
echo Using index info to reconstruct a base tree...
@@ -71,7 +71,7 @@ fall_back_3way () {
71
GIT_OBJECT_DIRECTORY="$O_OBJECT" &&
72
export GIT_INDEX_FILE GIT_OBJECT_DIRECTORY &&
73
git-read-tree "$base" &&
74
- git-apply --index &&
74
+ git-apply $binary --index &&
75
mv ../patch-merge-tmp-index ../patch-merge-index &&
76
echo "$base" >../patch-merge-base
77
) <"$dotest/patch" 2>/dev/null && break
@@ -98,7 +98,7 @@ fall_back_3way () {
98
}
99
100
prec=4
101
-dotest=.dotest sign= utf8= keep= skip= interactive= resolved=
101
+dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary=
102
103
while case "$#" in 0) break;; esac
104
do
@@ -113,6 +113,9 @@ do
113
--interacti|--interactiv|--interactive)
114
interactive=t; shift ;;
115
116
+ -b|--b|--bi|--bin|--bina|--binar|--binary)
117
+ binary=t; shift ;;
118
+
119
-3|--3|--3w|--3wa|--3way)
120
threeway=t; shift ;;
121
-s|--s|--si|--sig|--sign|--signo|--signof|--signoff)
@@ -169,9 +172,10 @@ else
172
exit 1
173
}
174
172
- # -s, -u and -k flags are kept for the resuming session after
175
+ # -b, -s, -u and -k flags are kept for the resuming session after
176
# a patch failure.
177
# -3 and -i can and must be given when resuming.
178
+ echo "$binary" >"$dotest/binary"
179
echo "$sign" >"$dotest/sign"
180
echo "$utf8" >"$dotest/utf8"
181
echo "$keep" >"$dotest/keep"
@@ -187,6 +191,10 @@ case "$resolved" in
191
fi
192
esac
193
194
+if test "$(cat "$dotest/binary")" = t
195
+then
196
+ binary=--allow-binary-replacement
197
+fi
198
if test "$(cat "$dotest/utf8")" = t
199
then
200
utf8=-u
@@ -339,7 +347,7 @@ do
347
348
case "$resolved" in
349
'')
342
- git-apply --index "$dotest/patch"
350
+ git-apply $binary --index "$dotest/patch"
351
apply_status=$?
352
;;
353
t)