summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2026-05-23 17:25:07 +0100
committerSean Whitton <spwhitton@spwhitton.name>2026-05-23 17:25:07 +0100
commit4f13f52a3aade6e43e42f14f9f94b0c43d6b4b12 (patch)
treecc8cf31fff04caf08e9d22540e4c5289ee5d5213
parentdd42133315b9aea8ed8ce54191a5e85249417a0c (diff)
* build-aux/git-hooks/commit-msg: Replace Markdown-style quotation.
-rwxr-xr-xbuild-aux/git-hooks/commit-msg16
1 files changed, 9 insertions, 7 deletions
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index 159990b1406..ddde1b4e586 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -75,6 +75,7 @@ exec $awk \
}
c_lower = "abcdefghijklmnopqrstuvwxyz"
unsafe_gnu_url = "(http|ftp)://([" c_lower ".]*\\.)?(gnu|fsf)\\.org"
+ markdown_quotation = "(^|[^\\\\])`[^'\''`]+`"
}
{ input[NR] = $0 }
@@ -92,11 +93,6 @@ exec $awk \
status = 1
}
- /(^|[^\\])`[^'\''`]+`/ {
- print "Markdown-style quotes in commit message"
- status = 1
- }
-
nlines == 0 && $0 !~ non_space { next }
{ nlines++ }
@@ -141,7 +137,7 @@ exec $awk \
status = 1
}
- $0 ~ unsafe_gnu_url {
+ $0 ~ unsafe_gnu_url || $0 ~ markdown_quotation {
needs_rewriting = 1
}
@@ -167,7 +163,13 @@ exec $awk \
suffix = substr(line, RSTART)
line = prefix "https:" substr(suffix, 5 + (suffix ~ /^http:/))
}
- print line >file
+ while (match(line, markdown_quotation)) {
+ prefix = substr(line, 1, RSTART)
+ within = substr(line, RSTART + 2, RLENGTH - 3)
+ suffix = substr(line, RSTART + RLENGTH)
+ line = prefix "'\''" within "'\''" suffix
+ }
+ print line >file
}
if (close(file) != 0) {
print "Cannot rewrite: " file