Skip to content

Instantly share code, notes, and snippets.

@lucaswerkmeister
Created April 11, 2014 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucaswerkmeister/10495164 to your computer and use it in GitHub Desktop.
Save lucaswerkmeister/10495164 to your computer and use it in GitHub Desktop.
Script to find mentions of git commit hashes in commit messages or diffs
(
commits=($(git log --pretty='format:%h' -S'\b[a-f0-9]{7,}\b' --pickaxe-{all,regex}));
commits+=($(git log --pretty='format:%h' --grep='\b[a-f0-9]\{7,\}\b'));
for commit in ${commits[*]}; do
for shaish in $(git show $commit | tail -n+5 | grep -v '^index' | grep -oe '[a-f0-9]\{7,\}'); do
if git rev-list HEAD.."$shaish" &> /dev/null; then
echo $shaish;
fi
done
done
) | sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment