Created
November 14, 2015 14:03
-
-
Save earthgecko/2450c5d24b6229e773fc to your computer and use it in GitHub Desktop.
Find a change in a git repo via a string in actually git diffs (not just commit messages)
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
# Find a change via a string in actually git diffs (not just commit messages) | |
GIT_REPO_DIR="<PATH_TO_YOU_REPO>" | |
TMP_DIR="/tmp" | |
STRING_TO_FIND="include openssh_server" | |
cd "$GIT_REPO_DIR" | |
> "${TMP_DIR}/git.rev.matches" | |
git rev-list HEAD | | |
while read rev; do | |
if git show -p $rev | grep "$STRING_TO_FIND" >/dev/null; then | |
echo $rev >> "${TMP_DIR}/git.rev.matches" | |
fi | |
done | |
for rev in $(cat "${TMP_DIR}/git.rev.matches") | |
do | |
git show $rev > "${TMP_DIR}/git.show.$rev" | |
if cat "${TMP_DIR}/git.show.$rev" | grep "$STRING_TO_FIND" > /dev/null; then | |
echo " | |
################# | |
# Found in $rev" | |
cat "${TMP_DIR}/git.show.$rev" | grep "$STRING_TO_FIND" | |
fi | |
done | |
# To see the whole git show do: | |
# cat "${TMP_DIR}/git.show.$rev" | |
# or | |
# git show $rev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment