From a09f31f9d39c3b16f67463f7a88f8ab917f5284f Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 10 Dec 2011 16:33:50 +0800 Subject: [PATCH] Added git bisect wrapper to find commit that removed text --- lib/git/tools.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/git/tools.sh b/lib/git/tools.sh index 767b988..15aed51 100644 --- a/lib/git/tools.sh +++ b/lib/git/tools.sh @@ -53,3 +53,25 @@ git_ignore() { git_exclude() { git_ignore "$1" ".git/info/exclude" } + + +# Use git bisect to find where text was removed from a file. +# +# Example: +# +# - Locate the commit where the text "strawberry" was removed from the file 'FRUITS'. +# - The text was not present in 992048f +# +# git_bisect_grep 992048f "strawberry" FRUITS +# +git_bisect_grep() { + if [ -z "$2" ]; then + echo "Usage: git_bisect_grep "; + exit 1 + fi + if [ -n "$3" ]; then search_path="$3"; else search_path="."; fi + git bisect start + git bisect good $1 + git bisect bad + git bisect run grep -qvRE "$2" $search_path +}