all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#19337: [PATCH] Improve git hook checking commit message.
@ 2014-12-10 17:24 Michal Nazarewicz
  2014-12-11  4:47 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Nazarewicz @ 2014-12-10 17:24 UTC (permalink / raw)
  To: 19337, eggert

From: Michal Nazarewicz <mina86@mina86.com>

* build-aux/git-hooks/commit-msg: Do not validate commit message if it
starts with “fixup!” or “squash!”.  Those are special markers used by
git when doing auto squashing and as a result the commit message will
not be used in the final commit.

* build-aux/git-hooks/commit-msg: Make the massages somehow more
ambiguous by mentioning that they error has been found in the commit
message.  Otherwise, user may be left wondering what the error is
referring to.
---
 build-aux/git-hooks/commit-msg | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index 6a09edd..f3b05db 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -42,7 +42,7 @@ exec awk '
   /^#/ { next }
 
   !/^.*$/ {
-    print "Invalid character (not UTF-8)"
+    print "Commit message contains invalid character (not UTF-8)"
     status = 1
   }
 
@@ -51,38 +51,47 @@ exec awk '
   { nlines++ }
 
   nlines == 1 && /^[[:space:]]/ {
-    print "White space at start of first line"
+    print "Commit message contains white space at start of first line"
     status = 1
   }
 
+  nlines == 1 && /^(fixup|squash)! / {
+    exit status
+  }
+
   nlines == 2 && /[^[:space:]]/ {
-    print "Nonempty second line"
+    print "Commit message must have an empty second line"
+    status = 1
+  }
+
+  /\t/ {
+    print "Use use spaces instead of tabs in commit message"
     status = 1
   }
 
   /[[:cntrl:]]/ {
-    print "Text contains control character; please use spaces instead of tabs"
+    print "Commit message contains control character"
     status = 1
   }
 
   72 < length && /[[:space:]]/ {
-    print "Line longer than 72 characters"
+    print "Commit message contains line longer than 72 characters"
     status = 1
   }
 
   140 < length {
-    print "Word longer than 140 characters"
+    print "Commit message contains word longer than 140 characters"
     status = 1
   }
 
   /^Signed-off-by: / {
-    print "'Signed-off-by:' present"
+    print "'Signed-off-by:' present in the commit message"
     status = 1
   }
 
   END {
     if (nlines == 0) {
-      print "Empty change log entry"
+      print "Empty commit message"
       status = 1
     }
     exit status
-- 
2.2.0.rc0.207.ga3a616c






^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#19337: [PATCH] Improve git hook checking commit message.
  2014-12-10 17:24 bug#19337: [PATCH] Improve git hook checking commit message Michal Nazarewicz
@ 2014-12-11  4:47 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2014-12-11  4:47 UTC (permalink / raw)
  To: Michal Nazarewicz, 19337-done

[-- Attachment #1: Type: text/plain, Size: 142 bytes --]

Thanks for reporting the problem.  I installed the attached patch in the 
emacs-24 branch; it should be merged into the master in due course.

[-- Attachment #2: 0001-Improve-commit-msg-messages-and-autosquash.patch --]
[-- Type: text/x-diff, Size: 3201 bytes --]

From c425a985e045e4e967f43a3d1e355c1f1faf5063 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 10 Dec 2014 20:44:35 -0800
Subject: [PATCH] Improve commit-msg messages and autosquash

Problem reported by Michal Nazarewicz in Bug#19337.
* build-aux/git-hooks/commit-msg: Add "commit message" to
diagnostics.  Distinguish better between tabs and other
unprintable chars in diagnostics.  Don't complain if a prefix
"fixup! " or "squash! " makes a summary line too long.
---
 ChangeLog                      |  9 +++++++++
 build-aux/git-hooks/commit-msg | 39 +++++++++++++++++++++++++--------------
 2 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4a7b590..d4a4f28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-12-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Improve commit-msg messages and autosquash
+	Problem reported by Michal Nazarewicz in Bug#19337.
+	* build-aux/git-hooks/commit-msg: Add "commit message" to
+	diagnostics.  Distinguish better between tabs and other
+	unprintable chars in diagnostics.  Don't complain if a prefix
+	"fixup! " or "squash! " makes a summary line too long.
+
 2014-12-08  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Port commit-message checking to FreeBSD 9.
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index f407881..d2a0c59 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -49,7 +49,7 @@ exec $awk '
   /^#/ { next }
 
   !/^.*$/ {
-    print "Invalid character (not UTF-8)"
+    print "Invalid character (not UTF-8) in commit message"
     status = 1
   }
 
@@ -57,39 +57,50 @@ exec $awk '
 
   { nlines++ }
 
-  nlines == 1 && /^[[:space:]]/ {
-    print "White space at start of first line"
-    status = 1
-  }
+  nlines == 1 {
+    # Ignore special markers used by "git rebase --autosquash".
+    if (! sub(/^fixup! /, ""))
+      sub(/^squash! /, "")
 
-  nlines == 2 && /[^[:space:]]/ {
-    print "Nonempty second line"
-    status = 1
+    if (/^[[:space:]]/) {
+      print "White space at start of commit message'\''s first line"
+      status = 1
+    }
   }
 
-  /[^[:print:]]/ {
-    print "Unprintable character; please use spaces instead of tabs"
+  nlines == 2 && /[^[:space:]]/ {
+    print "Nonempty second line in commit message"
     status = 1
   }
 
   72 < length && /[[:space:]]/ {
-    print "Line longer than 72 characters"
+    print "Line longer than 72 characters in commit message"
     status = 1
   }
 
   140 < length {
-    print "Word longer than 140 characters"
+    print "Word longer than 140 characters in commit message"
     status = 1
   }
 
   /^Signed-off-by: / {
-    print "'\''Signed-off-by:'\'' present"
+    print "'\''Signed-off-by:'\'' in commit message"
+    status = 1
+  }
+
+  /[^[:print:]]/ {
+    if (gsub(/\t/, "")) {
+      print "Tab in commit message; please use spaces instead"
+    }
+    if (/[^[:print:]]/) {
+      print "Unprintable character in commit message"
+    }
     status = 1
   }
 
   END {
     if (nlines == 0) {
-      print "Empty change log entry"
+      print "Empty commit message"
       status = 1
     }
     exit status
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-11  4:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-10 17:24 bug#19337: [PATCH] Improve git hook checking commit message Michal Nazarewicz
2014-12-11  4:47 ` Paul Eggert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.