bug-gnulib
[Top][All Lists]
Advanced

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

Re: maint.mk: absolute VPATH build fix


From: Akim Demaille
Subject: Re: maint.mk: absolute VPATH build fix
Date: Sun, 29 Jul 2012 13:24:30 +0200

Le 29 juil. 2012 à 13:09, Jim Meyering a écrit :

>> +      die "$ME: $qcmd had unexpected exit code or signal ($?)\n"
>> +        if $?;
> 
> I prefer to write it this way, putting the less-likely code in the
> indented clause:  (or testing $? != 0)
> 
>        $?
>          and die "$ME: $qcmd had unexpected exit code or signal ($?)\n"

Hi Jim!

Yes, I was annoyed by that too.  Since you allowed the "or die" version,
which I much prefer (so you can read consistently expected assertions
rather than a mixture of "must be true" and "must be false"), I installed
it as follows.

commit e91cb2e5c0d63e19918b18e1624afd9420dccc27
Author: Akim Demaille <address@hidden>
Date:   Sun Jul 29 08:46:55 2012 +0200

    gitlog-to-changelog: don't expect .git to be in $srcdir
    
    Reported by Bruno Haible.
    <http://lists.gnu.org/archive/html/bug-gnulib/2012-07/msg00265.html>
    
    * build-aux/gitlog-to-changelog (&git_dir_option): New.
    Use it.

diff --git a/ChangeLog b/ChangeLog
index 500006e..6806847 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2012-07-29  Akim Demaille  <address@hidden>
 
+       gitlog-to-changelog: don't expect .git to be in $srcdir
+       Reported by Bruno Haible.
+       <http://lists.gnu.org/archive/html/bug-gnulib/2012-07/msg00265.html>
+       * build-aux/gitlog-to-changelog (&git_dir_option): New.
+       Use it.
+
+2012-07-29  Akim Demaille  <address@hidden>
+
        maint.mk: absolute VPATH build fix
        * top/maint.mk (gpg_key_ID): Help git find .git when, for instance,
        $(srcdir) is not a parent of $(builddir).
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index d79e7aa..60e1c39 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-07-16 18:34'; # UTC
+my $VERSION = '2012-07-29 06:11'; # 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,7 +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.
-   --srcdir=DIR the root of the source tree, containing the '.git' directory.
+   --srcdir=DIR the root of the source tree, from which the .git/
+                  directory can be derived.
    --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;
@@ -193,6 +194,30 @@ sub parse_amend_file($)
   return $h;
 }
 
+# git_dir_option $SRCDIR
+#
+# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR
+# is undef).  Return as a list (0 or 1 element).
+sub git_dir_option($)
+{
+  my ($srcdir) = @_;
+  my @res = ();
+  if (defined $srcdir)
+    {
+      my $qdir = shell_quote $srcdir;
+      my $cmd = "cd $qdir && git rev-parse --show-toplevel";
+      my $qcmd = shell_quote $cmd;
+      my $git_dir = qx($cmd);
+      defined $git_dir
+        or die "$ME: cannot run $qcmd: $!\n";
+      $? != 0
+        or die "$ME: $qcmd had unexpected exit code or signal ($?)\n"
+      chomp $git_dir;
+      push @res, "--git-dir=$git_dir/.git";
+    }
+  @res;
+}
+
 {
   my $since_date;
   my $format_string = '%s%n%b%n';
@@ -224,7 +249,7 @@ sub parse_amend_file($)
   my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {};
 
   my @cmd = ('git',
-             defined $srcdir ? ("--git-dir=$srcdir/.git") : (),
+             git_dir_option $srcdir,
              qw(log --log-size),
              '--pretty=format:%H:%ct  %an  <%ae>%n%n'.$format_string, @ARGV);
   open PIPE, '-|', @cmd




reply via email to

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