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 ## applymbox [ -k ] [ -q ] (-c .dotest/msg-number | mail_archive) [Signoff_file]"
14 ## The patch application may fail in the middle. In which case:
15 ## (1) look at .dotest/patch and fix it up to apply
16 ## (2) re-run applymbox with -c .dotest/msg-number for the current one.
17 ## Pay a special attention to the commit log message if you do this and
18 ## use a Signoff_file, because applypatch wants to append the sign-off
19 ## message to msg-clean every time it is run.
21 . git-sh-setup-script || die
"Not a git archive"
23 keep_subject
= query_apply
= continue= resume
=t
24 while case "$#" in 0) break ;; esac
27 -k) keep_subject
=-k ;;
29 -c) continue="$2"; resume
=f
; shift ;;
40 git-mailsplit
"$1" .dotest ||
exit 1
44 files
=$
(git-diff-cache
--cached --name-only HEAD
) ||
exit
46 echo "Dirty index: cannot apply patches (dirty: $files)" >&2
50 case "$query_apply" in
51 t
) touch .dotest
/.query_apply
53 case "$keep_subject" in
54 -k) : >.dotest
/.keep_subject
60 while case "$#" in 0) break;; esac
63 case "$resume,$continue" in
67 git-mailinfo
$keep_subject \
68 .dotest
/msg .dotest
/patch <$i >.dotest
/info ||
exit 1
69 git-stripspace
< .dotest
/msg
> .dotest
/msg-clean
72 while :; # for fixing up and retry
74 git-applypatch .dotest
/msg-clean .dotest
/patch .dotest
/info
"$signoff"
77 # 2 is a special exit code from applypatch to indicate that
78 # the patch wasn't applied, but continue anyway
82 if test -f .dotest
/.query_apply
84 echo >&2 "* Patch failed."
85 echo >&2 "* You could fix it up in your editor and"
86 echo >&2 " retry. If you want to do so, say yes here"
87 echo >&2 " AFTER fixing .dotest/patch up."
88 echo >&2 -n "Retry [y/N]? "