bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] gitlog-to-changelog: fix git-log invocation


From: Jim Meyering
Subject: Re: [PATCH] gitlog-to-changelog: fix git-log invocation
Date: Tue, 01 Nov 2011 15:19:43 +0100

Dmitry V. Levin wrote:
> On Mon, Oct 31, 2011 at 05:11:28PM +0100, Jim Meyering wrote:
>> Dmitry V. Levin wrote:
>> > git-log mishandles date strings before 1970-01-01 UTC, and there is
>> > no use to specify --since=1970-01-01 by default anyway.
>> > * build-aux/gitlog-to-changelog: By default, when no --since option
>> > was given, do not specify explicit --since option to git-log.
>> ...
>> > -  my $since_date = '1970-01-01 UTC';
>> > +  my $since_date = '';
>>
>> No need for the initializer.
>>
>> >    my $format_string = '%s%n%b%n';
>> >    my $append_dot = 0;
>> >    GetOptions
>> > @@ -114,7 +114,12 @@ sub quoted_cmd(@)
>> >       'append-dot' => \$append_dot,
>> >      ) or usage 1;
>> >
>> > -  my @cmd = (qw (git log --log-size), "--since=$since_date",
>> > +  if ($since_date)
>> > +    {
>> > +      unshift(@ARGV, "--since=$since_date");
>> > +    }
>>
>> The above would fail to process any specified value that evaluates to 0.
>> Testing for definedness avoids that nit,
>> and I prefer the two-line construct to the 4-line one:
>>
>>   defined $since_date
>>     and unshift @ARGV, "--since=$since_date";
>
> Thanks for corrections.  Now gitlog-to-changelog without --since will
> hopefully work 24 hours a day. :)

Depending on your definition of "work", you could even say "forever" ;-)
Running it on coreutils, I got this, ad infinitum:

    Use of uninitialized value $line[0] in pattern match (m//) at 
build-aux/gitlog-to-changelog line 163, <PIPE> line 34755.


>From bc2f20935ff445f1e55b9c7f7e90cd77ef4eb007 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 1 Nov 2011 15:11:06 +0100
Subject: [PATCH] gitlog-to-changelog: avoid an infloop

* build-aux/gitlog-to-changelog: Don't infloop for a commit log
that ends up being empty.
---
 ChangeLog                     |    6 ++++++
 build-aux/gitlog-to-changelog |    7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 097de6c..1855e40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-11-01  Jim Meyering  <address@hidden>
+
+       gitlog-to-changelog: avoid an infloop
+       * build-aux/gitlog-to-changelog: Don't infloop for a commit log
+       that ends up being empty.
+
 2011-11-01  Bruno Haible  <address@hidden>

        New module 'fchownat', split off from module 'openat'.
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index c776313..4612d38 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -160,8 +160,11 @@ sub quoted_cmd(@)
       @line = grep !/^Signed-off-by: .*>$/, @line;

       # Remove leading and trailing blank lines.
-      while ($line[0] =~ /^\s*$/) { shift @line; }
-      while ($line[$#line] =~ /^\s*$/) { pop @line; }
+      if (@line)
+        {
+          while ($line[0] =~ /^\s*$/) { shift @line; }
+          while ($line[$#line] =~ /^\s*$/) { pop @line; }
+        }

       # If there were any lines
       if (@line == 0)
--
1.7.7.1.476.g9890



reply via email to

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