add -C[NUM] to git-am
Add -C[NUM] to git-am and git-rebase so that patches can be applied even if context has changed a bit. Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il> Signed-off-by: Junio C Hamano <junkio@cox.net>
Michael S. Tsirkin committed
Feb 8, 2007 at 15:57 UTC
67dad687ad15d26d8e26f4d27874af0bc0965ce2
4 files changed
+25
-6
Documentation/git-am.txt
+4
@@ -64,6 +64,10 @@ default. You could use `--no-utf8` to override this.
64
This flag is passed to the `git-apply` program that applies
65
the patch.
66
67
+-C<n>::
68
+ This flag is passed to the `git-apply` program that applies
69
+ the patch.
70
+
71
--interactive::
72
Run interactively, just like git-applymbox.
73
Documentation/git-rebase.txt
+7
-1
@@ -7,7 +7,7 @@ git-rebase - Forward-port local commits to the updated upstream head
7
8
SYNOPSIS
9
--------
10
-'git-rebase' [-v] [--merge] [--onto <newbase>] <upstream> [<branch>]
10
+'git-rebase' [-v] [--merge] [-CNUM] [--onto <newbase>] <upstream> [<branch>]
11
12
'git-rebase' --continue | --skip | --abort
13
@@ -196,6 +196,12 @@ OPTIONS
196
-v, \--verbose::
197
Display a diffstat of what changed upstream since the last rebase.
198
199
+-C<n>::
200
+ Ensure at least <n> lines of surrounding context match before
201
+ and after each change. When fewer lines of surrounding
202
+ context exist they all must match. By default no context is
203
+ ever ignored.
204
+
205
include::merge-strategies.txt[]
206
207
NOTES
git-am.sh
+8
-4
@@ -3,7 +3,7 @@
3
# Copyright (c) 2005, 2006 Junio C Hamano
4
5
USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]
6
- [--interactive] [--whitespace=<option>] <mbox>...
6
+ [--interactive] [--whitespace=<option>] [-CNUM] <mbox>...
7
or, when resuming [--skip | --resolved]'
8
. git-sh-setup
9
set_reflog_action am
@@ -106,7 +106,8 @@ It does not apply to blobs recorded in its index."
106
}
107
108
prec=4
109
-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= ws= resolvemsg=
109
+dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg=
110
+git_apply_opt=
111
112
while case "$#" in 0) break;; esac
113
do
@@ -142,7 +143,10 @@ do
143
skip=t; shift ;;
144
145
--whitespace=*)
145
- ws=$1; shift ;;
146
+ git_apply_opt="$git_apply_opt $1"; shift ;;
147
+
148
+ -C*)
149
+ git_apply_opt="$git_apply_opt $1"; shift ;;
150
151
--resolvemsg=*)
152
resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;;
@@ -394,7 +398,7 @@ do
398
399
case "$resolved" in
400
'')
397
- git-apply $binary --index $ws "$dotest/patch"
401
+ git-apply $git_apply_opt $binary --index "$dotest/patch"
402
apply_status=$?
403
;;
404
t)
git-rebase.sh
+6
-1
@@ -45,6 +45,7 @@ do_merge=
45
dotest=$GIT_DIR/.dotest-merge
46
prec=4
47
verbose=
48
+git_am_opt=
49
50
continue_merge () {
51
test -n "$prev_head" || die "prev_head must be defined"
@@ -213,6 +214,10 @@ do
214
-v|--verbose)
215
verbose=t
216
;;
217
+ -C*)
218
+ git_am_opt=$1
219
+ shift
220
+ ;;
221
-*)
222
usage
223
;;
@@ -322,7 +327,7 @@ fi
327
if test -z "$do_merge"
328
then
329
git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD |
325
- git am --binary -3 -k --resolvemsg="$RESOLVEMSG"
330
+ git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG"
331
exit $?
332
fi
333