diff options
author | Yves Orton <demerphq@gemini.(none)> | 2009-07-29 13:48:06 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gemini.(none)> | 2009-07-30 00:58:38 +0200 |
commit | b20f263759e67c18c512f1ae5e4c7157c7ec76b1 (patch) | |
tree | afaa6dfa279c8736723b8dd87f200d96e43a37ad /Porting/make_dot_patch.pl | |
parent | dc2f75c0f2e64ac8eee5e3138845de02223668f8 (diff) | |
download | perl-b20f263759e67c18c512f1ae5e4c7157c7ec76b1.tar.gz |
much much quicker solution
Diffstat (limited to 'Porting/make_dot_patch.pl')
-rwxr-xr-x | Porting/make_dot_patch.pl | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/Porting/make_dot_patch.pl b/Porting/make_dot_patch.pl index 6d2767c2e2..4cc7f84ff4 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"; |