In perl.git, the branch blead has been updated
<http://perl5.git.perl.org/perl.git/commitdiff/11a595870adcd875f29635df8e4b9a2d22c36521?hp=dc2f75c0f2e64ac8eee5e3138845de02223668f8>
- Log -----------------------------------------------------------------
commit 11a595870adcd875f29635df8e4b9a2d22c36521
Author: Yves Orton <demer...@gemini.(none)>
Date: Thu Jul 30 00:36:49 2009 +0200
we want the git-describe of the requested item, not the current head.
M Porting/GitUtils.pm
commit ed34cb0da30723d9663f4b9ef3c1e64b98d47ad5
Author: Yves Orton <demer...@gemini.(none)>
Date: Wed Jul 29 14:19:43 2009 +0200
convert the contents of make_dot_patch into a function and put it in
GitUtils
A Porting/GitUtils.pm
M Porting/make_dot_patch.pl
commit b20f263759e67c18c512f1ae5e4c7157c7ec76b1
Author: Yves Orton <demer...@gemini.(none)>
Date: Wed Jul 29 13:48:06 2009 +0200
much much quicker solution
M Porting/make_dot_patch.pl
-----------------------------------------------------------------------
Summary of changes:
Porting/GitUtils.pm | 60 +++++++++++++++++++++++++++++++++++++++++++++
Porting/make_dot_patch.pl | 26 ++-----------------
2 files changed, 63 insertions(+), 23 deletions(-)
create mode 100755 Porting/GitUtils.pm
diff --git a/Porting/GitUtils.pm b/Porting/GitUtils.pm
new file mode 100755
index 0000000..9ee6ca5
--- /dev/null
+++ b/Porting/GitUtils.pm
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use POSIX qw(strftime);
+
+use base qw/Exporter/;
+our @EXPORT_OK=qw(iso_time_with_dot gen_dot_patch);
+
+sub iso_time_with_dot {
+ strftime "%Y-%m-%d.%H:%M:%S",gmtime(shift||time)
+}
+
+# generate the contents of a .patch file for an arbitrary commitish, or for
HEAD if none is supplied
+# assumes the CWD is inside of a perl git repository. If the repository is
bare then refs/heads/*
+# is used to determine the branch. If the repository is not bare then
refs/remotes/origin/* is used
+# to determine the branch. (The assumption being that if its bare then this is
running inside of
+# the master git repo - if its not bare then it is a checkout which may not
have all the branches)
+sub gen_dot_patch {
+ 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';
+
+ # which branches to scan - the order here is important, the first hit we
find we use
+ # so if two branches can both reach a ref we want the right one first.
+ my @branches=(
+ 'blead',
+ 'maint-5.10',
+ 'maint-5.8',
+ 'maint-5.8-dor',
+ 'maint-5.6',
+ 'maint-5.005',
+ 'maint-5.004',
+ # and more generalized searches...
+ 'refs/heads/*',
+ 'refs/remotes/*',
+ 'refs/*',
+ );
+ my $reftype= $is_bare ? "heads" : "remotes/origin";
+ my $branch;
+ foreach my $name (@branches) {
+ my $refs= $name=~m!^refs/! ? $name : "refs/$reftype/$name";
+ my $cmd= "git name-rev --name-only --refs=$refs $sha1";
+ chomp($branch= `$cmd`);
+ last if $branch ne 'undefined';
+ }
+ for ($branch) {
+ $_ ||= "error"; # hmm, we didnt get /anything/ from
name-rev?
+ s!^\Q$reftype\E/!! || # strip off the reftype
+ s!^refs/heads/!! || # possible other places it was found
+ s!^refs/remotes/!! || # ...
+ s!^refs/!!; # might even be a tag or something
weirdo...
+ s![~^].*\z!!; # strip off how far we are from the item
+ }
+ my $tstamp= iso_time_with_dot(`git log -1 --pretty="format:%ct" $sha1`);
+ chomp(my $describe= `git describe $sha1`);
+ join(" ", $branch, $tstamp, $sha1, $describe);
+}
+
+1;
diff --git a/Porting/make_dot_patch.pl b/Porting/make_dot_patch.pl
index 6d2767c..b50fd85 100755
--- a/Porting/make_dot_patch.pl
+++ b/Porting/make_dot_patch.pl
@@ -20,28 +20,8 @@ use warnings;
#
# Yves
-use POSIX qw(strftime);
-sub isotime { strftime "%Y-%m-%d.%H:%M:%S",gmtime(shift||time) }
+use lib "Porting";
+use GitUtils qw(gen_dot_patch);
+print gen_dot_patch(@ARGV), -t STDOUT ? "\n" : "";
-my $sha1= shift || `git rev-parse HEAD`;
-chomp($sha1);
-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',
-);
-my $branch;
-foreach my $b (@branches) {
- $branch= $b and last
- if `git log --pretty='format:%H' $b | grep $sha1`;
-}
-
-$branch ||= "unknown-branch";
-my $tstamp= isotime(`git log -1 --pretty="format:%ct" $sha1`);
-chomp(my $describe= `git describe`);
-print join(" ", $branch, $tstamp, $sha1, $describe) . "\n";
--
Perl5 Master Repository