changeset 16873:d3ae42d4a75f

gitlog-to-changelog: support the log message format used in Bison. * build-aux/gitlog-to-changelog: Support --strip-tab and --strip-cherry-picked.
author Akim Demaille <akim@lrde.epita.fr>
date Tue, 22 May 2012 11:35:07 +0200
parents 9414f434742e
children d9a5a5ebbcbd
files ChangeLog build-aux/gitlog-to-changelog
diffstat 2 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-15  Akim Demaille  <akim@lrde.epita.fr>
+
+	gitlog-to-changelog: support the log message format used in Bison.
+	* build-aux/gitlog-to-changelog: Support --strip-tab and
+	--strip-cherry-picked.
+
 2012-05-21  Paolo Bonzini  <bonzini@gnu.org>
 
 	poll/select: prevent busy-waiting.  SwitchToThread() only gives away
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -3,7 +3,7 @@
     if 0;
 # Convert git log output to ChangeLog format.
 
-my $VERSION = '2012-01-18 07:50'; # UTC
+my $VERSION = '2012-05-22 09:40'; # 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
@@ -73,7 +73,10 @@
    --format=FMT set format string for commit subject and body;
                   see 'man git-log' for the list of format metacharacters;
                   the default is '%s%n%b%n'
-
+   --strip-tab  remove one additional leading TAB from commit message lines.
+   --strip-cherry-pick  remove data inserted by "git cherry-pick";
+                  this includes the "cherry picked from commit ..." line,
+                  and the possible final "Conflicts:" paragraph.
    --help       display this help and exit
    --version    output version information and exit
 
@@ -195,6 +198,8 @@
   my $amend_file;
   my $append_dot = 0;
   my $cluster = 1;
+  my $strip_tab = 0;
+  my $strip_cherry_pick = 0;
   GetOptions
     (
      help => sub { usage 0 },
@@ -204,6 +209,8 @@
      'amend=s' => \$amend_file,
      'append-dot' => \$append_dot,
      'cluster!' => \$cluster,
+     'strip-tab' => \$strip_tab,
+     'strip-cherry-pick' => \$strip_cherry_pick,
     ) or usage 1;
 
 
@@ -263,6 +270,13 @@
           $rest = $_;
         }
 
+      # Remove lines inserted by "git cherry-pick".
+      if ($strip_cherry_pick)
+        {
+          $rest =~ s/^\s*Conflicts:\n.*//sm;
+          $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m;
+        }
+
       my @line = split "\n", $rest;
       my $author_line = shift @line;
       defined $author_line
@@ -347,6 +361,10 @@
                 }
             }
 
+          # Remove one additional leading TAB from each line.
+          $strip_tab
+            and map { s/^\t// } @line;
+
           # Prefix each non-empty line with a TAB.
           @line = map { length $_ ? "\t$_" : '' } @line;