bin/get-fixes-pick-list.sh: bring back the warning
[mesa.git] / bin / get-fixes-pick-list.sh
1 #!/bin/sh
2
3 # Script for generating a list of candidates [referenced by a Fixes tag] for
4 # cherry-picking to a stable branch
5 #
6 # Usage examples:
7 #
8 # $ bin/get-fixes-pick-list.sh
9 # $ bin/get-fixes-pick-list.sh > picklist
10 # $ bin/get-fixes-pick-list.sh | tee picklist
11
12 # Use the last branchpoint as our limit for the search
13 latest_branchpoint=`git merge-base origin/master HEAD`
14
15 # List all the commits between day 1 and the branch point...
16 git log --reverse --pretty=%H $latest_branchpoint > already_landed
17
18 # ... and the ones cherry-picked.
19 git log --reverse --grep="cherry picked from commit" $latest_branchpoint..HEAD |\
20 grep "cherry picked from commit" |\
21 sed -e 's/^[[:space:]]*(cherry picked from commit[[:space:]]*//' -e 's/)//' > already_picked
22
23 # Grep for commits with Fixes tag
24 git log --reverse --pretty=%H -i --grep="fixes:" $latest_branchpoint..origin/master |\
25 while read sha
26 do
27 # Check to see whether the patch is on the ignore list ...
28 if [ -f bin/.cherry-ignore ] ; then
29 if grep -q ^$sha bin/.cherry-ignore ; then
30 continue
31 fi
32 fi
33
34 # Skip if it has been already cherry-picked.
35 if grep -q ^$sha already_picked ; then
36 continue
37 fi
38
39 # For each one try to extract the tag
40 fixes_count=`git show $sha | grep -i "fixes:" | wc -l`
41 warn=`(test $fixes_count -gt 1 && echo $fixes_count) || echo 0`
42 while [ $fixes_count -gt 0 ] ; do
43 fixes=`git show $sha | grep -i "fixes:" | tail -n $fixes_count`
44 fixes_count=$(($fixes_count-1))
45 # The following sed/cut combination is borrowed from GregKH
46 id=`echo ${fixes} | sed -e 's/^[ \t]*//' | cut -f 2 -d ':' | sed -e 's/^[ \t]*//' | cut -f 1 -d ' '`
47
48 # Bail out if we cannot find suitable id.
49 # Any specific validation the $id is valid and not some junk, is
50 # implied with the follow up code
51 if [ "x$id" = x ] ; then
52 continue
53 fi
54
55 # Check if the offending commit is in branch.
56
57 # Be that cherry-picked ...
58 # ... or landed before the branchpoint.
59 if grep -q ^$id already_picked ||
60 grep -q ^$id already_landed ; then
61
62 printf "Commit \"%s\" fixes %s\n" \
63 "`git log -n1 --pretty=oneline $sha`" \
64 "$id"
65 warn=$(($warn-1))
66 fi
67
68 done
69
70 if [ $warn -gt 0 ] ; then
71 printf "WARNING: Commit \"%s\" has more than one Fixes tag\n" \
72 "`git log -n1 --pretty=oneline $sha`"
73 fi
74
75 done
76
77 rm -f already_picked
78 rm -f already_landed