1#!/bin/sh
2
3# Script for generating a list of candidates for cherry-picking to a stable branch
4
5# Grep for commits with "cherry picked from commit" in the commit message.
6git log --reverse --grep="cherry picked from commit" origin/master..HEAD |\
7	grep "cherry picked from commit" |\
8	sed -e 's/^[[:space:]]*(cherry picked from commit[[:space:]]*//' -e 's/)//' > already_picked
9
10# Grep for commits that were marked as a candidate for the stable tree.
11git log --reverse --pretty=%H -i --grep='^[[:space:]]*NOTE: This is a candidate' HEAD..origin/master |\
12while read sha
13do
14	# Check to see whether the patch is on the ignore list.
15	if [ -f bin/.cherry-ignore ] ; then
16		if grep -q ^$sha bin/.cherry-ignore ; then
17			continue
18		fi
19	fi
20
21	# Check to see if it has already been picked over.
22	if grep -q ^$sha already_picked ; then
23		continue
24	fi
25
26	git log -n1 --pretty=oneline $sha | cat
27done
28
29rm -f already_picked
30