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.
This commit is contained in:
Michael Forney 2022-04-26 19:06:53 +00:00 committed by xfnw
parent fe1b02113e
commit d2942d4de3

View file

@ -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" {