diff options
Diffstat (limited to 'mailimport')
-rwxr-xr-x | mailimport | 119 |
1 files changed, 78 insertions, 41 deletions
diff --git a/mailimport b/mailimport index 6895fc32d..bd834123a 100755 --- a/mailimport +++ b/mailimport @@ -18,32 +18,8 @@ head=v4l/scripts/hghead.pl -if [ "$1" == "" ]; then - echo "Usage: $0 <mbox>" - exit -fi -MBOX=$1 - -if [ "$TMPDIR" == "" ]; then - TMPDIR=/tmp -fi - -if [ "$EDITOR" == "" ]; then - EDITOR="nano -w" -fi - -if [ "$CHECKPATCH" == "" ]; then - CHECKPATCH="/lib/modules/`uname -r`/build/scripts/checkpatch.pl" -fi - -DIR=$TMPDIR/mailimport$$ -mkdir $DIR -if [ "$?" != "0" ]; then - echo "*** Error at mkdir $DIR" - exit; -fi -trap "rm -rf $DIR" EXIT -TMP2=$DIR/patchheader +#################################################################### +# Tries to apply a patch at the tree apply_patch () { next=$1 @@ -159,26 +135,20 @@ apply_patch () { hg log -r -1 -v } -grep -v $MBOX >$DIR/tmpbox <<EOF -^Content-Type: -^--Boundary- -^Content-Disposition: inline -^Content-Transfer-Encoding: 8bit -EOF +#################################################################### +# Proccess a new patch -echo git-mailsplit -b $MBOX/tmpbox $DIR -echo -n "Number of patches at file: " -git-mailsplit -b $MBOX $DIR -echo +proccess_patch () +{ + i="$_" -for i in $DIR/*; do if [ "`diffstat -p1 -l $i`" == "" ]; then echo "*** ERROR nothing to commit" cd $cur exit fi - cat $i| git-mailinfo $DIR/msg $DIR/patch>$DIR/author + cat $i| git-mailinfo $DIR/msg $DIR/patch >$DIR/author cat $DIR/msg|grep -vi ^CC: >$DIR/msg2 cat $DIR/author|perl -ne "if (m/Author[:]\\s*(.*)\\n/) { \$auth=\$1; } else \ @@ -195,12 +165,79 @@ for i in $DIR/*; do cat $DIR/author2 - echo "Signed-off-by: $CHANGE_LOG_NAME <$CHANGE_LOG_EMAIL_ADDRESS>" >>$DIR/msg2 + sob="Signed-off-by: $CHANGE_LOG_NAME <$CHANGE_LOG_EMAIL_ADDRESS>" + + if [ "$(perl -ne 'if (m/$sob/) { print $_; }' $DIR/msg2)" == "" ]; then + echo $sob >>$DIR/msg2 + fi echo "cat $DIR/author2 $DIR/msg2 $DIR/patch >$out" $CHECKPATCH -q --notree $i|perl -ne '{ print "# $_"; }' >$out cat $DIR/author2 $DIR/msg2 $DIR/patch >>$out - apply_patch $out -done +} + +#################################################################### +# Main + +if [ "$1" == "" ]; then + echo "Usage: $0 <mbox>" + exit +fi + +if [ "$TMPDIR" == "" ]; then + TMPDIR=/tmp +fi + +if [ "$EDITOR" == "" ]; then + EDITOR="nano -w" +fi + +if [ "$CHECKPATCH" == "" ]; then + CHECKPATCH="/lib/modules/`uname -r`/build/scripts/checkpatch.pl" +fi + +DIR=$TMPDIR/mailimport$$ +mkdir $DIR +if [ "$?" != "0" ]; then + echo "*** Error at mkdir $DIR" + exit; +fi +trap "rm -rf $DIR" EXIT + +if [ -d "$1" ]; then + TMP2=$DIR/patchheader + + if [ -e "$1/series" ]; then + for i in `cat "$1/series"|grep -v "^#"`; do + echo $1/$i + proccess_patch "$1/$i" + done + else + for i in $1/*; do + proccess_patch $i + done + fi +else + MBOX="$1" + TMP2=$DIR/patchheader + + grep -v -f - $MBOX >$DIR/tmpbox <<EOF +^Content-Type: +^--Boundary- +^Content-Disposition: inline +^Content-Transfer-Encoding: 8bit +EOF + + echo git-mailsplit -b $DIR/tmpbox $DIR + echo -n "Number of patches at file: " + git-mailsplit -b $DIR/tmpbox $DIR + echo + + for i in $DIR/0*; do + echo $i + proccess_patch $i + done +fi + |