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" 11## 12## applymbox [ -q ] (-c .dotest/msg-number | mail_archive) [Signoff_file]" 13## 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. 20 21query_apply=continue= resume=t 22while case"$#"in0)break;;esac 23do 24case"$1"in 25-q) query_apply=t ;; 26-c)continue="$2"; resume=f;shift;; 27-*) usage ;; 28*)break;; 29esac 30shift 31done 32 33case"$continue"in 34'') 35rm-rf .dotest 36mkdir .dotest 37 git-mailsplit"$1" .dotest ||exit1 38shift 39esac 40 41case"$query_apply"in 42t)touch .dotest/.query_apply 43esac 44 45signoff="$1" 46set x .dotest/0* 47shift 48while case"$#"in0)break;;esac 49do 50 i="$1" 51case"$resume,$continue"in 52 f,$i) resume=t;; 53 f,*)continue;; 54*) 55 git-mailinfo .dotest/msg .dotest/patch<$i>.dotest/info ||exit1 56 git-stripspace< .dotest/msg > .dotest/msg-clean 57;; 58esac 59while:;# for fixing up and retry 60do 61 git-applypatch .dotest/msg-clean .dotest/patch .dotest/info "$signoff" 62case"$?"in 630|2) 64# 2 is a special exit code from applypatch to indicate that 65# the patch wasn't applied, but continue anyway 66;; 67*) 68 ret=$? 69iftest -f .dotest/.query_apply 70then 71echo>&2"* Patch failed." 72echo>&2"* You could fix it up in your editor and" 73echo>&2" retry. If you want to do so, say yes here" 74echo>&2" AFTER fixing .dotest/patch up." 75echo>&2-n"Retry [y/N]? " 76read yesno 77case"$yesno"in 78[Yy]*) 79continue;; 80esac 81fi 82exit$ret 83esac 84break 85done 86shift 87done 88# return to pristine 89rm-fr .dotest