Skip to content

Instantly share code, notes, and snippets.

@staticfloat
Created November 4, 2021 23:13
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 staticfloat/c5bca982edf15d7f550b2a841ade2e1f to your computer and use it in GitHub Desktop.
Save staticfloat/c5bca982edf15d7f550b2a841ade2e1f to your computer and use it in GitHub Desktop.
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