bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Feature request] gitlog-to-changelog: don't cluster multiple Change


From: Jim Meyering
Subject: Re: [Feature request] gitlog-to-changelog: don't cluster multiple ChangeLog entries under the same "date line"
Date: Mon, 26 Dec 2011 10:30:51 +0100

Stefano Lattarini wrote:

> On 12/23/2011 05:19 PM, Jim Meyering wrote:
>>>> However, I would prefer an adaptive/hybrid solution: if a commit log
>>>> is composed of two or more paragraphs, keep it in a separate block.
>>>> Otherwise, merge entries that would otherwise have a date--name--email
>>>> header identical to the preceding one.

I've implemented what I suggested.
I tested on coreutils, where it inserted 75 more headers into the
generated ChangeLog than the previous version of gitlog-to-changelog.

I think the result is an improvement, but it is still not as readable as I
would like, or maybe it's just not as readable as I am used to ("git log"
output).  Why? ...  Because when some clumped entries are adjacent to a
multi-paragraph one, the style dichotomy makes it a little harder to see
that each of the clumped entries does indeed correspond to its own commit.

What I guess I'm saying is that I see your point of view.
If you ever write the patch you want, with some new option,
I'll probably apply it here.


>From ba7a060ee406a05700ac89e1088a42a441f62fcf Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 25 Dec 2011 16:14:36 +0100
Subject: [PATCH] gitlog-to-changelog: do not clump multi-paragraph entries

Identical header lines (date,name,email+coauthors) are suppressed,
thus putting all entries with those same characteristics under
a single header.  However, when a log entry consists of two or
more paragraphs, it may not be clear where it starts and ends.
This change makes it so that such an entry is always separated
from others by a header line, even when that header would
otherwise be suppressed.
* build-aux/gitlog-to-changelog: Implement the above.
Inspired by a related request from Stefano Lattarini in
http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/29456
---
 ChangeLog                     |   14 +++++++++++++
 build-aux/gitlog-to-changelog |   42 ++++++++++++++++++++++++----------------
 2 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7ce1968..cc50b4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-12-25  Jim Meyering  <address@hidden>
+
+       gitlog-to-changelog: do not clump multi-paragraph entries
+       Identical header lines (date,name,email+coauthors) are suppressed,
+       thus putting all entries with those same characteristics under
+       a single header.  However, when a log entry consists of two or
+       more paragraphs, it may not be clear where it starts and ends.
+       This change makes it so that such an entry is always separated
+       from others by a header line, even when that header would
+       otherwise be suppressed.
+       * build-aux/gitlog-to-changelog: Implement the above.
+       Inspired by a related request from Stefano Lattarini in
+       http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/29456
+
 2011-12-25  Paul Eggert  <address@hidden>

        announce-gen: fix `cmd' typo in diagnostic
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 40a8035..ee1ac87 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 = '2011-11-02 07:53'; # UTC
+my $VERSION = '2011-12-24 18:51'; # 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
@@ -199,6 +199,7 @@ sub parse_amend_file($)
     or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n"
             . "(Is your Git too old?  Version 1.5.1 or later is required.)\n");

+  my $prev_multi_paragraph;
   my $prev_date_line = '';
   my @prev_coauthors = ();
   while (1)
@@ -248,12 +249,25 @@ sub parse_amend_file($)
       $author_line =~ /^(\d+)  (.*>)$/
         or die "$ME:$.: Invalid line "
           . "(expected date/author/email):\n$author_line\n";
-
       my $date_line = sprintf "%s  $2\n", strftime ("%F", localtime ($1));

+      my @coauthors = grep /^Co-authored-by:.*$/, @line;
+      # Omit "Co-authored-by..." and "Signed-off-by..." lines.
+      @line = grep !/^Signed-off-by: .*>$/, @line;
+      @line = grep !/^Co-authored-by: /, @line;
+
+      # Remove leading and trailing blank lines.
+      if (@line)
+        {
+          while ($line[0] =~ /^\s*$/) { shift @line; }
+          while ($line[$#line] =~ /^\s*$/) { pop @line; }
+        }
+
+      # Record whether there are two or more paragraphs.
+      my $multi_paragraph = grep /^\s*$/, @line;
+
       # Format 'Co-authored-by: A U Thor <address@hidden>' lines in
       # standard multi-author ChangeLog format.
-      my @coauthors = grep /^Co-authored-by:.*$/, @line;
       for (@coauthors)
         {
           s/^Co-authored-by:\s*/\t    /;
@@ -264,9 +278,13 @@ sub parse_amend_file($)
               . substr ($_, 5) . "\n";
         }

-      # If this header would be the same as the previous date/name/email/
-      # coauthors header, then arrange not to print it.
-      if ($date_line ne $prev_date_line or "@coauthors" ne "@prev_coauthors")
+      # If this header would be different from the previous date/name/email/
+      # coauthors header, or if this or the previous entry consists of two
+      # or more paragraphs, then print the header.
+      if ($date_line ne $prev_date_line
+          or "@coauthors" ne "@prev_coauthors"
+          or $multi_paragraph
+          or $prev_multi_paragraph)
         {
           $prev_date_line eq ''
             or print "\n";
@@ -276,17 +294,7 @@ sub parse_amend_file($)
         }
       $prev_date_line = $date_line;
       @prev_coauthors = @coauthors;
-
-      # Omit "Co-authored-by..." and "Signed-off-by..." lines.
-      @line = grep !/^Signed-off-by: .*>$/, @line;
-      @line = grep !/^Co-authored-by: /, @line;
-
-      # Remove leading and trailing blank lines.
-      if (@line)
-        {
-          while ($line[0] =~ /^\s*$/) { shift @line; }
-          while ($line[$#line] =~ /^\s*$/) { pop @line; }
-        }
+      $prev_multi_paragraph = $multi_paragraph;

       # If there were any lines
       if (@line == 0)
--
1.7.8.1.367.g25ecc



reply via email to

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