Created
January 13, 2023 09:27
-
-
Save smuuf/7fbdc12ab733e593e2933878a81b6574 to your computer and use it in GitHub Desktop.
Find string in git diff with info about function or class
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
#!/bin/bash | |
PREVIOUS="(@@.*function|class)" NEEDLE="getTraced" \ | |
bash -c 'git diff | awk "(/$PREVIOUS/ && !/$NEEDLE/) {capture=1; buffer = \$0; next} capture==1 {buffer = buffer \$0 \"\n\"} (\$capture && /$NEEDLE/) {printf(\"%s\", buffer); capture=0}"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment