diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-06-15 21:29:22 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-06-15 21:29:22 +0000 |
commit | 7c3ff535745b373775fbdab74954e7717abbce84 (patch) | |
tree | 0daf110dc3aeb98571251d95f486ef4a2afd45af | |
parent | 21283578ebbc2663e698733a6d11ace0e98bc8a9 (diff) | |
download | plan9front-7c3ff535745b373775fbdab74954e7717abbce84.tar.xz |
git/import: handle mails with line wrapping and mime
git/import expected a patch, however upas/fs serves
either a raw file without any of the mime decoding
and line joining, or a directory, with the headers
and body split out.
This makes it a pain to apply some mails.
So, here we teach git to import upas dirs natively,
making it easy to handle all patches that come in
as emails.
-rwxr-xr-x | sys/src/cmd/git/import | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/src/cmd/git/import b/sys/src/cmd/git/import index 3d1424143..c89d52d6b 100755 --- a/sys/src/cmd/git/import +++ b/sys/src/cmd/git/import @@ -37,7 +37,7 @@ fn apply @{ date=$0 } state=="headers" && /^Subject:/{ - sub(/^Subject:[ \t]*(\[PATCH( [0-9]+\/[0-9]+)?\])*[ \t]*/, "", $0); + sub(/^Subject:[ \t]*(\[[^\]]*\][ \t]*)*/, "", $0); gotmsg = 1 print > "/env/msg" } @@ -94,6 +94,14 @@ eval `''{aux/getflags $*} || exec aux/usage patches=(/fd/0) if(! ~ $#* 0) patches=$* -for(f in $patches) - apply < $f || die $status +for(p in $patches){ + # upas serves the decoded header and body separately, + # so we cat them together when applying a upas message. + # + # this allows mime-encoded or line-wrapped patches. + if(test -d $p && test -f $p/header && test -f $p/body) + {{cat $p/header; echo; cat $p/body} | apply} || die $status + if not + apply < $p || die $status +} exit '' |