ref: bcc42916932abfaa9a832c721e8aec394fbea695
dir: /export/
#!/bin/rc rfork ne . /sys/lib/git/common.rc usage=' git/export [-o patchdir] [query] ' gitup ramfs stdout='true' patchdir='.' while(~ $1 -* && ! ~ $1 --){ switch($1){ case -o stdout='false' shift; patchdir=$1 if(! test -d $patchdir) mkdir -p $patchdir } shift } if(~ $1 --) shift q=$* if(~ $#q 0) q=HEAD commits=`{git/query $q || die $status} n=1 m=$#commits mntgen /mnt/scratch for(c in $commits){ cp=`{git/query -p $c} pp=`{git/query -p $c'^'} @{ rfork n cd /mnt/scratch bind $pp/tree a bind $cp/tree b echo From $c echo From: `{cat $cp/author} echo Date: `{date -m `{mtime $cp/author | awk '{print $1}'}} <$cp/msg awk ' BEGIN {RS = ""; FS = "\n"} NR == 1 { n = ENVIRON["n"] m = ENVIRON["m"] if(m > 1) patch = sprintf("[PATCH %d/%d]", n, m) else patch = "[PATCH]" printf "Subject: %s", patch for(i = 1; i <= NF; i++) msg = msg " " $i printf "%s\n\n", msg gsub("^[ ]|[ ]$", "", msg) gsub("[/ ]", "-", msg) printf "%.4d-%s.patch", n, msg >"/tmp/patchname" next } {print; printf "\n"}' ape/diff -urN a b } >/tmp/patchfile if(~ $stdout true){ cat /tmp/patchfile ! ~ $n $m && echo } if not mv /tmp/patchfile $patchdir/`{cat /tmp/patchname} n=`{echo $n + 1 | bc} }