summaryrefslogtreecommitdiff
path: root/sys/src/cmd/git
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2022-04-26 19:06:53 +0000
committerMichael Forney <mforney@mforney.org>2022-04-26 19:06:53 +0000
commit798375ad4531e944f18c4b4cc4c45f00b678ec9f (patch)
tree1ca709b392af16d0cc78b20be8badba0ac3964be /sys/src/cmd/git
parent99d69b52b3fa59b3c4414f1d3a711b3ba18ef52e (diff)
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.
Diffstat (limited to 'sys/src/cmd/git')
-rwxr-xr-xsys/src/cmd/git/import9
1 files changed, 8 insertions, 1 deletions
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" {