bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gitlog-to-changelog: improve gitmerge.el commits


From: Paul Eggert
Subject: [PATCH] gitlog-to-changelog: improve gitmerge.el commits
Date: Sat, 20 Jun 2015 10:10:39 -0700

From: Glenn Morris <address@hidden>

Let the Emacs ChangeLog generation process exclude "skipped"
messages from merge commits (Bug#20717).
* build-aux/gitlog-to-changelog: Handle gitmerge.el skipped commits.
---
 ChangeLog                     |  7 +++++++
 build-aux/gitlog-to-changelog | 43 ++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2901d77..051e06f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-06-20  Glenn Morris  <address@hidden>
+
+       gitlog-to-changelog: improve gitmerge.el commits
+       Let the Emacs ChangeLog generation process exclude "skipped"
+       messages from merge commits (Bug#20717).
+       * build-aux/gitlog-to-changelog: Handle gitmerge.el skipped commits.
+
 2015-06-20  Paul Eggert  <address@hidden>
 
        wchar: fix MinGW compilation warnings
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 9abb693..0cab1bf 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
     if 0;
 # Convert git log output to ChangeLog format.
 
-my $VERSION = '2015-05-19 01:37'; # UTC
+my $VERSION = '2015-06-11 01:03'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -270,6 +270,7 @@ sub git_dir_option($)
   my $prev_multi_paragraph;
   my $prev_date_line = '';
   my @prev_coauthors = ();
+  my @skipshas = ();
   while (1)
     {
       defined (my $in = <PIPE>)
@@ -290,6 +291,21 @@ sub git_dir_option($)
       $sha =~ /^[0-9a-fA-F]{40}$/
         or die "$ME:$.: invalid SHA1: $sha\n";
 
+      my $skipflag = 0;
+      if (@skipshas)
+        {
+          foreach(@skipshas)
+            {
+              if ($sha =~ /^$_/)
+                {
+                  $skipflag = 1;
+                  ## Perhaps only warn if a pattern matches more than once?
+                  warn "$ME: warning: skipping $sha due to $_\n";
+                  last;
+                }
+            }
+        }
+
       # If this commit's log requires any transformation, do it now.
       my $code = $amend_code->{$sha};
       if (defined $code)
@@ -348,9 +364,30 @@ sub git_dir_option($)
           while ($line[$#line] =~ /^\s*$/) { pop @line; }
         }
 
+      # Handle Emacs gitmerge.el "skipped" commits.
+      # Yes, this should be controlled by an option.  So sue me.
+      if ( grep /^(; )?Merge from /, @line )
+      {
+          my $found = 0;
+          foreach (@line)
+          {
+              if (grep /^The following commit.*skipped:$/, $_)
+              {
+                  $found = 1;
+                  ## Reset at each merge to reduce chance of false matches.
+                  @skipshas = ();
+                  next;
+              }
+              if ($found && $_ =~ /^([0-9a-fA-F]{7,}) [^ ]/)
+              {
+                  push ( @skipshas, $1 );
+              }
+          }
+      }
+
       # Ignore commits that match the --ignore-matching pattern, if specified.
-      if (! (defined $ignore_matching
-             && @line && $line[0] =~ /$ignore_matching/))
+      if (! ($skipflag || (defined $ignore_matching
+             && @line && $line[0] =~ /$ignore_matching/)))
         {
           if (defined $ignore_line && @line)
             {
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]