#!/bin/bash # # Check if a given commit is in the current branch, based on the subject # rather than commit sha1. # if [ "$#" -ne 1 ]; then echo "Usage: stable commit-in-tree " exit 1 fi fullhash=$(git rev-parse $1) # This might happen if someone pointed to a commit that doesn't exist in our # tree. if [ "$?" -gt "0" ]; then exit 0 fi # Hope for the best, same commit is/isn't in the current branch if [ "$(git merge-base $fullhash HEAD)" = "$fullhash" ]; then exit 1 fi # Grab the subject, since commit sha1 is different between branches we # have to look it up based on subject. subj=$(git log -1 --pretty="%s" $1) if [ $? -gt 0 ]; then exit 0 fi STABLE_MAJ_VER=$(grep VERSION Makefile | head -n1 | awk {'print $3'}) STABLE_MIN_VER=$(grep PATCHLEVEL Makefile | head -n1 | awk {'print $3'}) # Try and find if there's a commit with given subject the hard way for i in $(git log --pretty="%H" -F --grep "$subj" v$STABLE_MAJ_VER.$STABLE_MIN_VER..HEAD); do cursubj=$(git log -1 --format="%s" $i) if [ "$cursubj" = "$subj" ]; then exit 1 fi done exit 0