blob: 2019b3ae2e3d52d4ca4e4e82a38aaff7b9de4b83 [file] [log] [blame]
#!/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 <commit sha1>"
exit 1
fi
fullhash=$(git rev-parse $1)
# 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
# Try and find if there's a commit with given subject the hard way
for i in $(git log --pretty="%H" -F --grep "$subj" $STABLE_BASE..HEAD); do
cursubj=$(git log -1 --format="%s" $i)
if [ "$cursubj" = "$subj" ]; then
exit 1
fi
done
exit 0