gitlog-to-changelog: support the log message format used in Bison.
authorAkim Demaille <akim@lrde.epita.fr>
Tue, 22 May 2012 09:35:07 +0000 (11:35 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 22 May 2012 14:13:01 +0000 (16:13 +0200)
* build-aux/gitlog-to-changelog: Support --strip-tab and
--strip-cherry-picked.

ChangeLog
build-aux/gitlog-to-changelog

index cbc2dd0..e00c8bb 100644 (file)
--- 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
index 38c6f3a..17c4562 100755 (executable)
@@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
     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 @@ OPTIONS:
    --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 @@ sub parse_amend_file($)
   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 @@ sub parse_amend_file($)
      '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 @@ sub parse_amend_file($)
           $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 @@ sub parse_amend_file($)
                 }
             }
 
+          # 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;