-# Handle stable special to look for the annotated tag
-if [ "$branch" == "stable" ] ; then
- describe=$(git describe $head 2>/dev/null)
+potential=" "
+for branch in ${contains[@]} ; do
+ branch=${branch##origin/}
+ #echo "branch=$branch"
+
+ # Walk back until we hit a baserev that is not the branch_tip itself (because it was merged)
+ branch_tip=$(git rev-parse origin/$branch)
+ stable_rev=$(git rev-parse origin/stable)
+ stable_base=$(git merge-base "$branch_tip" "$stable_rev")
+
+ # echo "stable_base=$stable_base"
+ while [ "$stable_base" == "$branch_tip" ] ; do
+ stable_rev=$(git rev-parse "${stable_rev}^")
+ stable_base=$(git merge-base "$branch_tip" "$stable_rev")
+ done
+ # echo "stable_base=$stable_base"
+
+ git rev-list --first-parent $stable_base..$branch_tip | grep --quiet "$head"