develooper Front page | perl.perl5.porters | Postings from December 2011

Re: make_patchnum.pl broken?

Thread Previous
From:
Dave Mitchell
Date:
December 12, 2011 04:51
Subject:
Re: make_patchnum.pl broken?
Message ID:
20111212125101.GG2743@iabyn.com
On Sat, Nov 26, 2011 at 10:18:32PM -0800, zengargoyle wrote:
> So, I'm trying to build a Perl with some local modifications, using Git
> and sorta expecting some interesting information to show up in git_version.h
> and lib/Config_git.pl and nothing is happening....
> 
> I think this patch was bad:
> 
> ----
> commit 9077509c9b9bc1871867a5fba4351b95c670298d
> Author: David Mitchell <davem@iabyn.com>
> Date:   Sat Jul 3 16:47:05 2010 +0100
> 
>     make_patchnum.pl: handle not on a branch properly
> 
> diff --git a/make_patchnum.pl b/make_patchnum.pl
> index ac32808..03cb54a 100644
> --- a/make_patchnum.pl
> +++ b/make_patchnum.pl
> @@ -133,7 +133,7 @@ if (my $patch_file= read_file(".patch")) {
>  }
>  elsif (-d "$srcdir/.git") {
>      # git branch | awk 'BEGIN{ORS=""} /\*/ { print $2 }'
> -    ($branch) = map { /\* ([^(]\S*)/ ? $1 : () } backtick("git branch");
> +    ($branch) = map { /\* ([^(]\S*)/ ? $1 : "" } backtick("git branch");
>      my ($remote,$merge);
>      if (length $branch) {
>          $merge= backtick("git config branch.$branch.merge");
> ----
> 
> because a `git branch` that looks like:
> 
>   blead
> * newperl
>   uscperl
> 
> ends up with $branch = "" and the rest of make_patchnum.pl goes awry.
> 
> I'm not sure what this is supposed to do or what problem it was supposed to fix,
> but this seems broken.

Thanks for spotting this. Fixed with the following:

commit ee205375a963f0d44c8728cf881169683c9b912d
Author:     David Mitchell <davem@iabyn.com>
AuthorDate: Mon Dec 12 12:42:46 2011 +0000
Commit:     David Mitchell <davem@iabyn.com>
CommitDate: Mon Dec 12 12:48:12 2011 +0000

    fix make_patchnum.pl branch determination
    
    A previous commit of mine, 9077509c9b9bc1871867a5fba4351b95c670298d,
    tried to handle the case where the output of 'git branch' was
    
        * (no branch)
          blead
    
    to stop it outputting  a 'Use of uninitialized value' warning.
    However, my "fix" broke in the case where multiple branches are listed
    with the current not the first:
    
          blead
        * tmp1
          tmp2
    
    Hopefully this fixes it properly.


Affected files ...
    
    M	make_patchnum.pl

Differences ...

diff --git a/make_patchnum.pl b/make_patchnum.pl
index fcbfc6c..9d83dd5 100644
--- a/make_patchnum.pl
+++ b/make_patchnum.pl
@@ -133,7 +133,8 @@ if (my $patch_file= read_file(".patch")) {
 }
 elsif (-d "$srcdir/.git") {
     # git branch | awk 'BEGIN{ORS=""} /\*/ { print $2 }'
-    ($branch) = map { /\* ([^(]\S*)/ ? $1 : "" } backtick("git branch");
+    ($branch) = map { /\* ([^(]\S*)/ ? $1 : () } backtick("git branch");
+    $branch //= "";
     my ($remote,$merge);
     if (length $branch) {
         $merge= backtick("git config branch.$branch.merge");


-- 
Standards (n). Battle insignia or tribal totems.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About