Created
March 27, 2017 16:28
-
-
Save ttaylorr/3c1fb0c843d2f3387dff044b382084b8 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
name="$1" | |
if [ -z "$name" ]; then | |
echo >&2 "usage: "$0" <filename>" | |
exit 1 | |
fi | |
what="$(git ls-files -s | grep "\t$name$" | awk '{ print $2 }')" | |
while read l; do | |
sha="$(echo "$l" | awk '{ print $1 }')" | |
tree="$(git ls-tree "$sha" -r)" | |
dtree="$(git diff-tree -r --no-commit-id "$sha")" | |
found="$(echo "$tree" | grep -c "$what")" | |
dfound="$(echo "$dtree" | awk '{ print $4 }' | grep "$what")" | |
if [ "0" -ne "$found" ]; then | |
echo " found $what in $sha"; | |
fi | |
if [ ! -z "$dfound" ]; then | |
echo "$what introduced in $sha"; | |
exit 0 | |
fi | |
done < <(git log --oneline) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment