changeset 30625:989cb43cdf7b

gitlog-to-changelog: pass all command-line arguments to git-log When producing a ChangeLog, it is sometimes convenient to filter the commits in various ways. gitlog-to-changelog only allows --since to specify a start date, but git-log itself supports many other filtering mechanisms. At the moment, I want to filter by branch name. Rather than adding a --branch option to gitlog-to-changelog, it seems more flexible to simply pass all options directly to git-log and let git do the work. Notice that this effectively makes --since a redundant option for gitlog-to-changelog, but removing it would require current usage to change since calls would then require an additional '--'.
author William Pursell <bill.pursell@gmail.com>
date Sun, 21 Dec 2008 11:24:13 +0000
parents 530017954760
children ee27cc445c8e
files ChangeLog build-aux/gitlog-to-changelog
diffstat 2 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Dec 21 14:47:35 2008 +0100
+++ b/ChangeLog	Sun Dec 21 11:24:13 2008 +0000
@@ -1,3 +1,18 @@
+2008-12-21  William Pursell  <bill.pursell@gmail.com>
+
+	gitlog-to-changelog: pass all command-line arguments to git-log
+	* build-aux/gitlog-to-changelog: When producing a ChangeLog,
+	it is sometimes convenient to filter the commits in various ways.
+	gitlog-to-changelog only allows --since to specify a start date,
+	but git-log itself supports many other filtering mechanisms.
+	At the moment, I want to filter by branch name.  Rather than
+	adding a --branch option to gitlog-to-changelog, it seems more
+	flexible to simply pass all options directly to git-log and let
+	git do the work.  Notice that this effectively makes --since a
+	redundant option for gitlog-to-changelog, but removing it would
+	require current usage to change since calls would then require
+	an additional '--'.
+
 2008-12-21  Bruno Haible  <bruno@clisp.org>
 
 	* modules/mbsnrtowcs-tests: New file.
--- a/build-aux/gitlog-to-changelog	Sun Dec 21 14:47:35 2008 +0100
+++ b/build-aux/gitlog-to-changelog	Sun Dec 21 11:24:13 2008 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # Convert git log output to ChangeLog format.
 
-my $VERSION = '2008-08-19 05:01'; # UTC
+my $VERSION = '2008-12-21 12:07'; # 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
@@ -50,9 +50,11 @@
   else
     {
       print $STREAM <<EOF;
-Usage: $ME [OPTIONS]
+Usage: $ME [OPTIONS] [ARGS]
 
-Convert git log output to ChangeLog format.
+Convert git log output to ChangeLog format.  If present, any ARGS
+are passed to "git log".  To avoid ARGS being parsed as options to
+$ME, they may be preceded by '--'.
 
 OPTIONS:
 
@@ -65,6 +67,7 @@
 EXAMPLE:
 
   $ME --since=2008-01-01 > ChangeLog
+  $ME -- -n 5 foo > last-5-commits-to-branch-foo
 
 EOF
     }
@@ -100,11 +103,8 @@
      'since=s' => \$since_date,
     ) or usage 1;
 
-  @ARGV
-    and (warn "$ME: too many arguments\n"), usage 1;
-
   my @cmd = (qw (git log --log-size), "--since=$since_date",
-             '--pretty=format:%ct  %an  <%ae>%n%n%s%n%b%n');
+             '--pretty=format:%ct  %an  <%ae>%n%n%s%n%b%n', @ARGV);
   open PIPE, '-|', @cmd
     or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n"
             . "(Is your Git too old?  Version 1.5.1 or later is required.)\n");