From: Yves Orton Date: Wed, 29 Jul 2009 11:48:06 +0000 (+0200) Subject: much much quicker solution X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b20f263759e67c18c512f1ae5e4c7157c7ec76b1;p=p5sagit%2Fp5-mst-13.2.git much much quicker solution --- diff --git a/Porting/make_dot_patch.pl b/Porting/make_dot_patch.pl index 6d2767c..4cc7f84 100755 --- a/Porting/make_dot_patch.pl +++ b/Porting/make_dot_patch.pl @@ -23,24 +23,29 @@ use warnings; use POSIX qw(strftime); sub isotime { strftime "%Y-%m-%d.%H:%M:%S",gmtime(shift||time) } -my $sha1= shift || `git rev-parse HEAD`; -chomp($sha1); +my $target= shift || 'HEAD'; +chomp(my ($git_dir, $is_bare, $sha1)=`git rev-parse --git-dir --is-bare-repository $target`); +die "Not in a git repository!" if !$git_dir; +$is_bare= "" if $is_bare and $is_bare eq 'false'; my @branches=( - 'origin/blead', - 'origin/maint-5.10', - 'origin/maint-5.8', - 'origin/maint-5.8-dor', - 'origin/maint-5.6', - 'origin/maint-5.005', - 'origin/maint-5.004', + 'blead', + 'maint-5.10', + 'maint-5.8', + 'maint-5.8-dor', + 'maint-5.6', + 'maint-5.005', + 'maint-5.004', ); +my $reftype= $is_bare ? "heads" : "remotes/origin"; my $branch; -foreach my $b (@branches) { - $branch= $b and last - if `git log --pretty='format:%H' $b | grep $sha1`; +foreach my $name (@branches) { + my $cmd= "git name-rev --name-only --refs=refs/$reftype/$name $sha1"; + chomp($branch= `$cmd`); + last if $branch ne 'undefined'; } - -$branch ||= "unknown-branch"; +$branch ||= "error"; +$branch =~ s!^\Q$reftype\E/!!; +$branch =~ s![~^].*\z!!; my $tstamp= isotime(`git log -1 --pretty="format:%ct" $sha1`); chomp(my $describe= `git describe`); print join(" ", $branch, $tstamp, $sha1, $describe) . "\n";