ref: 04dcec15808653507789cf4d2a50a9e1ff7f26cc
parent: 3c8043a49b5e57509aa9d32f042b9d113b803235
author: kvik <kvik@a-b.xyz>
date: Thu Apr 9 13:23:14 EDT 2020
Wash the message before commiting The cleaning is equivalent to that of git(1).
--- a/commit
+++ b/commit
@@ -39,8 +39,20 @@
die 'invalid branch:' $branch
}
+# Remove commentary lines.
+# Remove leading and trailing empty lines.
+# Combine consecutive empty lines between paragraphs.
+# Remove trailing spaces from lines.
+# Ensure there's trailing newline.
fn cleanmsg{
- grep -v '^[ ]*#'
+ awk '
+ /^[ ]*#/ {next}
+ /^[ ]*$/ {empty = 1; next}
+
+ wet && empty {printf "\n"}
+ {wet = 1; empty = 0}
+ {sub(/[ ]+$/, ""); print $0}
+ '
}
fn editmsg{