From a5bde10b9021d9f48ef2bc4dd598d93a32eacdf4 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 22 May 2012 11:35:07 +0200 Subject: [PATCH] gitlog-to-changelog: support the log message format used in Bison. * build-aux/gitlog-to-changelog: Support --strip-tab and --strip-cherry-picked. --- ChangeLog | 6 ++++++ build-aux/gitlog-to-changelog | 22 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cbc2dd0cb..e00c8bb5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-05-15 Akim Demaille + + 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 poll/select: prevent busy-waiting. SwitchToThread() only gives away diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog index 38c6f3aaa..17c456271 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 = '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; -- 2.11.0