What's cooking (2013/12 #01)
[alt-git.git] / CheckPush
blobfcdc059b785d4069a31ca6ab8c1e550b0308d197
1 #!/bin/sh
3 for range in $(
4 prev_branch=
6 git for-each-ref --format='%(refname)' refs/heads/maint-* |
7 perl -e '
8 sub compare_dotted_version {
9 my (@ours) = split(/\./, $_[0]);
10 my (@theirs) = split(/\./, $_[1]);
11 my ($i, $diff);
13 for ($i = 0; $i < @ours && $i < @theirs; $i++) {
14 $diff = $ours[$i] - $theirs[$i];
15 return $diff if ($diff);
17 return 1 if ($i < @ours);
18 return -1 if ($i < @theirs);
19 return 0;
21 my @maint = ();
22 while (<STDIN>) {
23 next unless s|^refs/heads/||;
24 chomp;
25 my ($v) = ($_ =~ /^maint-(.*)$/);
26 push @maint, [$v, $_];
28 for (map { $_->[1] }
29 sort { compare_dotted_version($a->[0], $b->[0]) }
30 @maint) {
31 print "$_\n";
34 cat <<-EOF
35 maint
36 master
37 next
38 EOF
39 } |
40 while read branch
42 if test -n "$prev_branch"
43 then
44 echo "$branch..$prev_branch"
46 prev_branch=$branch
47 done
48 ) pu..jch
50 lg=$(git log --oneline "$range")
51 if test -n "$lg"
52 then
53 echo "*** $range ***"
54 echo "$lg"
56 done
58 if next_tree=$(git rev-parse next^{tree}) &&
59 next_equiv=$(git rev-list --first-parent master..pu |
60 xargs -n1 sh -c '
61 echo $(git rev-parse $1^{tree}) $1
62 ' - | sed -n -e "s/^$next_tree //p"
63 ) &&
64 test -n "$next_equiv"
65 then
66 jch=$(git rev-list --first-parent master..jch | wc -l) &&
67 pu=$(git rev-list --first-parent master..pu | wc -l) &&
68 next=$(git rev-list --first-parent master..$next_equiv | wc -l) &&
69 if test $jch -le $next
70 then
71 echo "master..$jch..jch..$next..next..$pu..pu"
72 else
73 echo "master..$next..next..$jch..jch..$pu..pu"
75 else
76 echo "git diff --stat next jch"
77 git diff --stat next jch