3 ## "dotest" is my stupid name for my patch-application script, which
4 ## I never got around to renaming after I tested it. We're now on the
5 ## second generation of scripts, still called "dotest".
7 ## Update: Ryan Anderson finally shamed me into naming this "applymbox".
9 ## You give it a mbox-format collection of emails, and it will try to
10 ## apply them to the kernel using "applypatch"
12 ## The patch application may fail in the middle. In which case:
13 ## (1) look at .dotest/patch and fix it up to apply
14 ## (2) re-run applymbox with -c .dotest/msg-number for the current one.
15 ## Pay a special attention to the commit log message if you do this and
16 ## use a Signoff_file, because applypatch wants to append the sign-off
17 ## message to msg-clean every time it is run.
19 . git-sh-setup || die
"Not a git archive"
22 echo >&2 "applymbox [-u] [-k] [-q] [-m] (-c .dotest/<num> | mbox) [signoff]"
26 keep_subject
= query_apply
= continue= utf8
= resume
=t
27 while case "$#" in 0) break ;; esac
31 -k) keep_subject
=-k ;;
33 -c) continue="$2"; resume
=f
; shift ;;
34 -m) fallback_3way
=t
;;
45 git-mailsplit
"$1" .dotest ||
exit 1
49 files
=$
(git-diff-index
--cached --name-only HEAD
) ||
exit
51 echo "Dirty index: cannot apply patches (dirty: $files)" >&2
55 case "$query_apply" in
56 t
) touch .dotest
/.query_apply
58 case "$fall_back_3way" in
61 case "$keep_subject" in
62 -k) : >.dotest
/.keep_subject
68 while case "$#" in 0) break;; esac
71 case "$resume,$continue" in
76 git-mailinfo
$keep_subject $utf8 \
77 .dotest
/msg .dotest
/patch <$i >.dotest
/info ||
exit 1
78 git-stripspace
< .dotest
/msg
> .dotest
/msg-clean
81 while :; # for fixing up and retry
83 git-applypatch .dotest
/msg-clean .dotest
/patch .dotest
/info
"$signoff"
86 # 2 is a special exit code from applypatch to indicate that
87 # the patch wasn't applied, but continue anyway
91 if test -f .dotest
/.query_apply
93 echo >&2 "* Patch failed."
94 echo >&2 "* You could fix it up in your editor and"
95 echo >&2 " retry. If you want to do so, say yes here"
96 echo >&2 " AFTER fixing .dotest/patch up."
97 echo >&2 -n "Retry [y/N]? "