Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helper script to find a treehash in a git repository
#!/bin/bash
if [[ -z "$1" ]]; then
echo "Usage: git-find-treehash <treehash>" >&2
exit 1
fi
commits=$(git log --pretty='%H %T' $commithash | grep $1 | awk '{print $1}')
if [[ -n "${commits}" ]]; then
echo "Found at commits: $commits"
exit 0
else
echo "Unable to find any commits with treehash $1" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment