git-am foreign patch support: introduce patch_format
Set up a framework to allow git-am to support patches which are not in mailbox format. Introduce a patch_format variable that presently can only be set from the command line, defaulting to 'mbox' (the only supported format) if not specified. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Giuseppe Bilotta committed
May 27, 2009 at 11:25 UTC
a5a6755a1d4707bf2fab7752e5c974ebf63d086a
1 file changed
+33
-4
git-am.sh
+33
-4
@@ -18,6 +18,7 @@ whitespace= pass it through git-apply
18
directory= pass it through git-apply
19
C= pass it through git-apply
20
p= pass it through git-apply
21
+patch-format= format the patch(es) are in
22
reject pass it through git-apply
23
resolvemsg= override error message when patch failure occurs
24
r,resolved to be used after a patch failure
@@ -133,6 +134,32 @@ It does not apply to blobs recorded in its index."
134
unset GITHEAD_$his_tree
135
}
136
137
+patch_format=
138
+
139
+check_patch_format () {
140
+ # early return if patch_format was set from the command line
141
+ if test -n "$patch_format"
142
+ then
143
+ return 0
144
+ fi
145
+ patch_format=mbox
146
+}
147
+
148
+split_patches () {
149
+ case "$patch_format" in
150
+ mbox)
151
+ git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
152
+ rm -fr "$dotest"
153
+ exit 1
154
+ }
155
+ ;;
156
+ *)
157
+ echo "Patch format $patch_format is not supported."
158
+ exit 1
159
+ ;;
160
+ esac
161
+}
162
+
163
prec=4
164
dotest="$GIT_DIR/rebase-apply"
165
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
@@ -175,6 +202,8 @@ do
202
git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
203
-C|-p)
204
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
205
+ --patch-format)
206
+ shift ; patch_format="$1" ;;
207
--reject)
208
git_apply_opt="$git_apply_opt $1" ;;
209
--committer-date-is-author-date)
@@ -274,10 +303,10 @@ else
303
done
304
shift
305
fi
277
- git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
278
- rm -fr "$dotest"
279
- exit 1
280
- }
306
+
307
+ check_patch_format "$@"
308
+
309
+ split_patches "$@"
310
311
# -s, -u, -k, --whitespace, -3, -C and -p flags are kept
312
# for the resuming session after a patch failure.