shithub: git9

Download patch

ref: b3ef69e810d95f6f45fdbd1fe3ae1da909a95438
parent: 18a105d86b21117847b635369c54929da57b350c
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Dec 3 02:53:00 EST 2019

less import message mangling

--- a/import
+++ b/import
@@ -38,10 +38,12 @@
 	}
 	state=="headers" && /^Subject:/{
 		sub(/^Subject: (\[PATCH\])*[ \t]*/, "", $0);
-		msg=msg $0 "\n"
+		gotmsg = 1
+		print > "/env/msg"
 	}
 	state=="headers" && /^$/ {
 		state="body"
+		next
 	}
 	(state=="headers" || state=="body") && (/^diff/ || /^---[ 	]*$/){
 		state="diff"
@@ -56,11 +58,10 @@
 	END{
 		if(state != "diff")
 			exit("malformed patch: " state);
-		if(name == "" || email == "" || msg == "" || date == "")
+		if(name == "" || email == "" || date == "" || gotmsg == "")
 			exit("missing headers");
 		printf "%s", name > "/env/name"
 		printf "%s", email > "/env/email"
-		printf "%s", msg > "/env/msg"
 		printf "%s", date > "/env/date"
 	}
 	' || die 'could not import:' $status
@@ -69,7 +70,7 @@
 	rc -c '
 		echo applying $msg | sed 1q
 		date=`{seconds $date}
-		files=`$nl{ape/patch -p1 < $diffpath | sed ''s/^patching file `(.*)''''/\1/''}
+		files=`$nl{ape/patch -Ep1 < $diffpath | sed ''s/^patching file `(.*)''''/\1/''}
 		for(f in $files){
 			if(test -e $f)
 				git/add $f