[PATCH] Warning fix for gcc 4
[git/jrn.git] / tools / git-applymbox
blobe44f5d7970deda7e28566c526be558c5a0c6cc3b
1 #!/bin/sh
2 ##
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".
6 ##
7 ## Update: Ryan Anderson finally shamed me into naming this "applymbox".
8 ##
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 [ -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 query_apply= continue= resume=t
22 while case "$#" in 0) break ;; esac
24 case "$1" in
25 -q) query_apply=t ;;
26 -c) continue="$2"; resume=f; shift ;;
27 -*) usage ;;
28 *) break ;;
29 esac
30 shift
31 done
33 case "$continue" in
34 '')
35 rm -rf .dotest
36 mkdir .dotest
37 git-mailsplit "$1" .dotest || exit 1
38 shift
39 esac
41 case "$query_apply" in
42 t) touch .dotest/.query_apply
43 esac
45 signoff="$1"
46 set x .dotest/0*
47 shift
48 while case "$#" in 0) break;; esac
50 i="$1"
51 case "$resume,$continue" in
52 f,$i) resume=t;;
53 f,*) continue;;
55 git-mailinfo .dotest/msg .dotest/patch <$i >.dotest/info || exit 1
56 git-stripspace < .dotest/msg > .dotest/msg-clean
58 esac
59 while :; # for fixing up and retry
61 git-applypatch .dotest/msg-clean .dotest/patch .dotest/info "$signoff"
62 case "$?" in
63 0 | 2 )
64 # 2 is a special exit code from applypatch to indicate that
65 # the patch wasn't applied, but continue anyway
68 ret=$?
69 if test -f .dotest/.query_apply
70 then
71 echo >&2 "* Patch failed."
72 echo >&2 "* You could fix it up in your editor and"
73 echo >&2 " retry. If you want to do so, say yes here"
74 echo >&2 " AFTER fixing .dotest/patch up."
75 echo >&2 -n "Retry [y/N]? "
76 read yesno
77 case "$yesno" in
78 [Yy]*)
79 continue ;;
80 esac
82 exit $ret
83 esac
84 break
85 done
86 shift
87 done
88 # return to pristine
89 rm -fr .dotest