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: Mon, 31 Oct 2011 17:11:28 +0100

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";

> +
> +  my @cmd = (qw (git log --log-size),
>               '--pretty=format:%ct  %an  <%ae>%n%n'.$format_string, @ARGV);
>    open PIPE, '-|', @cmd
>      or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n"

Thanks.  I've pushed this:

>From 3aee0dcbd2f2ee665609b1d338940c021db7d484 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <address@hidden>
Date: Mon, 31 Oct 2011 19:56:52 +0400
Subject: [PATCH] gitlog-to-changelog: fix git-log invocation

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.
---
 ChangeLog                     |    8 ++++++++
 build-aux/gitlog-to-changelog |    9 ++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a692aa9..f68a9b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-10-31  Dmitry V. Levin  <address@hidden>
+
+       gitlog-to-changelog: fix git-log invocation.
+       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.
+
 2011-10-30  Dmitry V. Levin  <address@hidden>

        gitlog-to-changelog: new option --append-dot.
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index c3a5ef3..c776313 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-10-31 07:45'; # UTC
+my $VERSION = '2011-10-31 16:06'; # 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
@@ -102,7 +102,7 @@ sub quoted_cmd(@)
 }

 {
-  my $since_date = '1970-01-01 UTC';
+  my $since_date;
   my $format_string = '%s%n%b%n';
   my $append_dot = 0;
   GetOptions
@@ -114,7 +114,10 @@ sub quoted_cmd(@)
      'append-dot' => \$append_dot,
     ) or usage 1;

-  my @cmd = (qw (git log --log-size), "--since=$since_date",
+  defined $since_date
+    and unshift @ARGV, "--since=$since_date";
+
+  my @cmd = (qw (git log --log-size),
              '--pretty=format:%ct  %an  <%ae>%n%n'.$format_string, @ARGV);
   open PIPE, '-|', @cmd
     or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n"
--
1.7.7.1.476.g9890



reply via email to

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