Last active
September 22, 2025 16:26
-
-
Save rosston/261409dedb971f51706bfecf12d2eb40 to your computer and use it in GitHub Desktop.
git-log-s-batch
This file contains hidden or 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 | |
| set -e | |
| # git-log-s-batch.sh | |
| # | |
| # Take in a newline-separated list of strings to look for with `git log -S` in | |
| # the current directory. Prints out all the strings that had some result when | |
| # run through `git log -S`. | |
| # | |
| # Usage: | |
| # echo "foo\nbar" | git-log-s-batch.sh | |
| # cat list-of-things.txt | git-log-s-batch.sh | |
| # git-log-s-batch.sh < list-of-things.txt | |
| matches=() | |
| while IFS=$'\n' read -r line; do | |
| if [[ $(git log -S "$line") ]]; then | |
| matches+=("$line") | |
| fi | |
| done | |
| matches_len=${#matches[@]} | |
| if [[ $matches_len -eq 0 ]]; then | |
| echo "No matches found" | |
| exit 0 | |
| fi | |
| echo "Matches found:" | |
| echo "" | |
| echo "${matches[*]}" | sed 's| |\n|g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment