README.md · 651 B · Markdown Raw
# gitfindfirst.sh A shell script for finding the first commit that introduced a search term into a git repository. ## Pre-reqs * [git](https://git-scm.com/) * [ack](https://beyondgrep.com/) ## Installation 1. Install the pre-reqs 2. Download `gitfindfirst.sh` and `noack.sh` 3. Place both these sripts in the same directory 4. Make them both executable (e.g. `chmod +x gitfindfirst.sh`). ## Usage Given a search term present at HEAD, issue: ~~~ gitfindfirst.sh SearchTerm ~~~ Search terms are specified using `ack` syntax. To search for a single word (e.g. IpcOneShotServer), simply specify that word: ~~~ gitfindfirst.sh IpcOneShotServer ~~~
gitfindfirst.sh
A shell script for finding the first commit that introduced a search term into a git repository.
Pre-reqs
Installation
- Install the pre-reqs
- Download
gitfindfirst.sh
andnoack.sh
- Place both these sripts in the same directory
- Make them both executable (e.g.
chmod +x gitfindfirst.sh
).
Usage
Given a search term present at HEAD, issue:
gitfindfirst.sh SearchTerm
Search terms are specified using ack
syntax. To search for a single word (e.g. IpcOneShotServer), simply specify that word:
gitfindfirst.sh IpcOneShotServer
gitfindfirst.sh · 507 B · Bash Raw
#!/usr/bin/env bash set -e # First check that the search target represented by the ack args are present at HEAD ACK_ARGS="$@" if ! ack -1 $ACK_ARGS; then echo "Error: search target '$ACK_ARGS' not found at HEAD" echo "Tip: checkout a revision containing the search target and try again." exit 1 fi SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) git bisect start HEAD $(git rev-list --max-parents=0 HEAD) git bisect run $SCRIPT_DIR/noack.sh $ACK_ARGS git bisect reset
1 | #!/usr/bin/env bash |
2 | set -e |
3 | |
4 | # First check that the search target represented by the ack args are present at HEAD |
5 | ACK_ARGS="$@" |
6 | if ! ack -1 $ACK_ARGS; then |
7 | echo "Error: search target '$ACK_ARGS' not found at HEAD" |
8 | echo "Tip: checkout a revision containing the search target and try again." |
9 | exit 1 |
10 | fi |
11 | |
12 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) |
13 | git bisect start HEAD $(git rev-list --max-parents=0 HEAD) |
14 | git bisect run $SCRIPT_DIR/noack.sh $ACK_ARGS |
15 | git bisect reset |
license.txt · 1.0 KiB · Text Raw
Copyright © 2025 Glyn Normington Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 | Copyright © 2025 Glyn Normington |
2 | |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation |
4 | files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, |
5 | modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
6 | Software is furnished to do so, subject to the following conditions: |
7 | |
8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
9 | |
10 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
11 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
13 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |