From ffc75aa710efc8796f0f34c30216ce8a2b1e3954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20M=C3=A1rton?= Date: Wed, 16 Mar 2022 23:21:04 +0100 Subject: [PATCH] git-hooks: echo back the commit message on failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using nano as a git commit message editor the contents of the commit message could get lost if the git commit hook fails due to the lack of Signed-off-by line. To prevent this unpleasant effect for new contributors the commit hook was modified to echo back the commit message to allow the user to copy-paste it to the message of the next commit attempt. Change-Id: I13289f81b3fa92640aecc43eae28c1643cd7c247 Signed-off-by: Miklós Márton Reviewed-on: https://review.coreboot.org/c/flashrom/+/62879 Reviewed-by: Peter Marheine Reviewed-by: Anastasia Klimchuk Tested-by: build bot (Jenkins) --- util/git-hooks/commit-msg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/git-hooks/commit-msg b/util/git-hooks/commit-msg index d43eb4529..e2f5de512 100755 --- a/util/git-hooks/commit-msg +++ b/util/git-hooks/commit-msg @@ -196,6 +196,7 @@ _gen_ChangeId() { test_signoff() { if ! grep -qi '^[[:space:]]*\+Signed-off-by:' "$MSG"; then + cat "$MSG" printf "\nError: No Signed-off-by line in the commit message.\n" printf "See: ${DEV_GUIDELINES_URL}\n" exit 1 @@ -206,6 +207,7 @@ test_signoff() { test_duplicate_signoffs_acks() { test "" = "$(grep -i '^(Signed-off-by|Acked-by): ' "$MSG" | sort | uniq -c | sed -e '/^[[:space:]]*1[[:space:]]/d')" || { + cat "$MSG" echo "Duplicate Signed-off-by or Acked-by lines." >&2 exit 1 }