[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gitlog-to-changelog option --tear-off
From: |
Jim Meyering |
Subject: |
Re: gitlog-to-changelog option --tear-off |
Date: |
Sat, 18 Feb 2012 21:08:19 +0100 |
Werner Koch wrote:
> On Sun, 12 Feb 2012 22:48, address@hidden said:
>
>> Hard-coding "--"...
My point was that we may not want to hard-code "--".
What if someone includes email with a "--" line followed by a signature?
...
> Okay. Here comes the fixed patch:
>
>
>>From 816b5f0f0928e257f7a4d78205be2a1935a58660 Mon Sep 17 00:00:00 2001
> From: Werner Koch <address@hidden>
> Date: Mon, 30 Jan 2012 19:10:21 +0100
> Subject: [PATCH] gitlog-to-changelog: add option --tear-off.
>
> This option allows to have blurbs in a commit messages, which shall
> not be copied to the ChangeLog. It can also be used to suppress an
> entire log entry.
> * build-aux/gitlog-to-changelog: New option --tear-off.
> ---
> build-aux/gitlog-to-changelog | 24 +++++++++++++++++++++++-
> 1 files changed, 23 insertions(+), 1 deletions(-)
>
> diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
> index 38c6f3a..070c9c7 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-02-16 09:53'; # 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
> @@ -68,6 +68,8 @@ OPTIONS:
> header; the default is to cluster adjacent commit messages
> if their headers are the same and neither commit message
> contains multiple paragraphs.
> + --tear-off tear off all commit log lines after a '--' line and
> + skip log entries with the first body line being '--'.
> --since=DATE convert only the logs since DATE;
> the default is to convert all log entries.
> --format=FMT set format string for commit subject and body;
> @@ -195,6 +197,7 @@ sub parse_amend_file($)
> my $amend_file;
> my $append_dot = 0;
> my $cluster = 1;
> + my $tear_off = 0;
> GetOptions
> (
> help => sub { usage 0 },
> @@ -204,6 +207,7 @@ sub parse_amend_file($)
> 'amend=s' => \$amend_file,
> 'append-dot' => \$append_dot,
> 'cluster!' => \$cluster,
> + 'tear-off' => \$tear_off,
> ) or usage 1;
>
>
> @@ -236,6 +240,10 @@ sub parse_amend_file($)
> $n_read == $log_nbytes
> or die "$ME:$.: unexpected EOF\n";
>
> + # Skip log entries if the body starts with a tear off marker.
> + $tear_off && $log =~ /^.*\n\n.*\n--\s*\n/
> + and goto SKIPCOMMIT;
> +
> # Extract leading hash.
> my ($sha, $rest) = split ':', $log, 2;
> defined $sha
> @@ -286,6 +294,19 @@ sub parse_amend_file($)
> |Copyright-paperwork-exempt:[ ]
> )/x, @line;
>
> + # Remove everything after a line with 2 dashes at the beginning.
> + if ($tear_off)
> + {
> + my @tmpline;
> + foreach (@line)
> + {
> + /^--\s*$/
> + and last;
> + push @tmpline, $_;
> + }
> + @line = @tmpline;
> + }
Hi Werner,
Is the first test-and-goto hunk required?
If so, doesn't it belong *after* the block that can transform
a commit log?
I would have thought that your latter hunk would be enough.
I.e., I propose the following adjustment to your change:
(also moving --tear-off down to where it'd go if all options
were alphabetized and adjusting its wording, and moving another comment)
I'd also add an entry in the ChangeLog file.
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 070c9c7..a73decb 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -68,13 +68,13 @@ OPTIONS:
header; the default is to cluster adjacent commit messages
if their headers are the same and neither commit message
contains multiple paragraphs.
- --tear-off tear off all commit log lines after a '--' line and
- skip log entries with the first body line being '--'.
--since=DATE convert only the logs since DATE;
the default is to convert all log entries.
--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'
+ --tear-off if a commit log body line matches /^--\s*$/, elide that
+ line and all following lines.
--help display this help and exit
--version output version information and exit
@@ -240,10 +240,6 @@ sub parse_amend_file($)
$n_read == $log_nbytes
or die "$ME:$.: unexpected EOF\n";
- # Skip log entries if the body starts with a tear off marker.
- $tear_off && $log =~ /^.*\n\n.*\n--\s*\n/
- and goto SKIPCOMMIT;
-
# Extract leading hash.
my ($sha, $rest) = split ':', $log, 2;
defined $sha
@@ -294,9 +290,9 @@ sub parse_amend_file($)
|Copyright-paperwork-exempt:[ ]
)/x, @line;
- # Remove everything after a line with 2 dashes at the beginning.
if ($tear_off)
{
+ # If a line matches /^--\s*$/, elide it and all following lines.
my @tmpline;
foreach (@line)
{
@@ -374,7 +370,6 @@ sub parse_amend_file($)
print "\n", join ("\n", @line), "\n";
}
- SKIPCOMMIT:
defined ($in = <PIPE>)
or last;
$in ne "\n"