Skip to content

Instantly share code, notes, and snippets.

@wenjianhn
Created April 29, 2014 03:43
Show Gist options
  • Save wenjianhn/11390206 to your computer and use it in GitHub Desktop.
Save wenjianhn/11390206 to your computer and use it in GitHub Desktop.
Check if a patch has already been merged as a specified commit.
#!/bin/bash
if [[ -z $2 ]]; then
echo -e "Usage:\n $0 <patch> <commit>"
exit 1
fi
PATCH=$1
COMMIT=$2
merged='not'
if [[ $(sed -n -e '/diff --git/,$p' ${PATCH} | sha1sum) = \
$(git show ${COMMIT} | sed -n -e '/diff --git/,$p' | sha1sum) ]]; then
merged=
fi
echo ${PATCH} has ${merged} been merged as commit ${COMMIT}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment