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