From d2942d4de3b5033ca8e24c13016e5bdf5aa4c61a Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 26 Apr 2022 19:06:53 +0000 Subject: [PATCH] git/import: squash leading/trailing/consecutive blanks and strip trailing space This fixes importing patches with multiline commit messages generated by git-format-patch. It also matches commit message sanitation done by git-am. --- sys/src/cmd/git/import | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/src/cmd/git/import b/sys/src/cmd/git/import index d8470dd01..7ba7d0e48 100755 --- a/sys/src/cmd/git/import +++ b/sys/src/cmd/git/import @@ -45,12 +45,19 @@ fn apply @{ } state=="headers" && /^$/ { state="body" - next } (state=="headers" || state=="body") && (/^diff / || /^---( |$)/){ state="diff" } + state=="body" && /^[ ]*$/ { + empty=1 + next + } state=="body" { + if(empty) + printf "\n" > "/env/msg" + empty=0 + sub(/[ ]+$/, "") print > "/env/msg" } state=="diff" {