]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Meta/CheckPush: minor versions could have more than one digit
authorJunio C Hamano <gitster@pobox.com>
Tue, 19 Jun 2012 22:19:51 +0000 (15:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Jun 2012 22:19:51 +0000 (15:19 -0700)
Add compare_dotted_version helper and use it

Signed-off-by: Junio C Hamano <gitster@pobox.com>
CheckPush

index 7ce0d9a411f94dd44ab05b269683619f574d3c37..fcdc059b785d4069a31ca6ab8c1e550b0308d197 100755 (executable)
--- a/CheckPush
+++ b/CheckPush
@@ -4,7 +4,33 @@ for range in $(
        prev_branch=
        {
                git for-each-ref --format='%(refname)' refs/heads/maint-* |
-               sed -e 's|^refs/heads/||'
+               perl -e '
+                       sub compare_dotted_version {
+                               my (@ours) = split(/\./, $_[0]);
+                               my (@theirs) = split(/\./, $_[1]);
+                               my ($i, $diff);
+
+                               for ($i = 0; $i < @ours && $i < @theirs; $i++) {
+                                       $diff = $ours[$i] - $theirs[$i];
+                                       return $diff if ($diff);
+                               }
+                               return 1 if ($i < @ours);
+                               return -1 if ($i < @theirs);
+                               return 0;
+                       }
+                       my @maint = ();
+                       while (<STDIN>) {
+                               next unless s|^refs/heads/||;
+                               chomp;
+                               my ($v) = ($_ =~ /^maint-(.*)$/);
+                               push @maint, [$v, $_];
+                       }
+                       for (map { $_->[1] }
+                            sort { compare_dotted_version($a->[0], $b->[0]) }
+                            @maint) {
+                               print "$_\n";
+                       }
+               '
                cat <<-EOF
                maint
                master