Created
September 3, 2015 23:00
-
-
Save laanwj/ef8a6dcbb02313442462 to your computer and use it in GitHub Desktop.
Find/show merge commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage() { | |
echo "git-merge-point <commitid>" | |
exit 1 | |
} | |
[ -n "$1" ] || usage | |
# Make sure we are in a git directory | |
git rev-parse --is-inside-work-tree >&- || exit $? | |
# Get commit name and upstream name | |
commit="$1" | |
upstream="${2:-HEAD}" | |
# Get list merges leading from $commit to $upstream | |
IFS=$'\n' read -d '' -r -a ancestry < \ | |
<(git rev-list --ancestry-path --merges "$commit..$upstream" --) | |
# Get list of merges directly into $upstream | |
IFS=$'\n' read -d '' -r -a merges < \ | |
<(git rev-list --first-parent --merges "$commit..$upstream" -- | tac) | |
# Find merge point | |
for merge in "${merges[@]}"; do | |
for sha in "${ancestry[@]}"; do | |
if [ "$sha" = "$merge" ]; then | |
echo $sha | |
exit 0 | |
fi | |
done | |
done | |
echo 'not merged' >&2 | |
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage() { | |
echo "git-show-merge <commitid>" | |
exit 1 | |
} | |
[ -n "$1" ] || usage | |
COMMIT=$(git-merge-point $1) | |
[ -n "$COMMIT" ] || { | |
echo "Not found or never merged" | |
exit 1 | |
} | |
git show --show-signature $COMMIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment