From b332f4cf3b2b49f2d170215cbd757c42f7e5dd98 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 18 Nov 2011 19:59:40 +0100 Subject: less ugly merge detection in log message (cherry picked from commit d326a1cc11c5c3bed3733db85a1f52b20fee093e) --- git-hooks/sanitize-commit | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index c931994..750248b 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -78,10 +78,14 @@ my $ln = 0; my $iswip = defined($cfg{wip}); my $revok = defined($cfg{revby}); my $badlog = defined($cfg{log}); +my $parents = 0; open MSG, "git log -1 --pretty=raw ".$sha1." |" or die "cannot run git: $!"; while () { chomp; - s/^ // or next; + if (!s/^ //) { + $parents++ if (/^parent /); + next + } if ($ln == 0) { $summary = $_; if (!$iswip && /\bWIP\b|\*{3}|^(?:squash|fixup)! |^(.)\1*$/i) { @@ -92,7 +96,7 @@ while () { } elsif (!$badlog && length($_) > 120) { &complain("Log message summary is excessively long", "log"); $badlog = 1; - } elsif (length($_) > 70 && !/^Merge ((remote )?branch '[^ ]+'|branch '[^ ]+' of [^ ]+( into [^ ]+)?)$/) { + } elsif ($parents < 2 && length($_) > 70) { &complain("Aim for shorter log message summaries", "", -1); } } elsif ($ln == 1) { -- cgit v1.2.1