summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rwxr-xr-xgit-grep.sh20
2 files changed, 21 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 5b028b1..9c2bdd6 100644
--- a/Makefile
+++ b/Makefile
@@ -76,7 +76,7 @@ SCRIPT_SH = \
git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
git-applymbox.sh git-applypatch.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
- git-merge-resolve.sh
+ git-merge-resolve.sh git-grep.sh
SCRIPT_PERL = \
git-archimport.perl git-cvsimport.perl git-relink.perl \
diff --git a/git-grep.sh b/git-grep.sh
new file mode 100755
index 0000000..db2296c
--- /dev/null
+++ b/git-grep.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+flags=
+while :; do
+ pattern="$1"
+ case "$pattern" in
+ -i|-I|-a|-E|-H|-h|-l)
+ flags="$flags $pattern"
+ shift
+ ;;
+ -*)
+ echo "unknown flag $pattern" >&2
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+shift
+git-ls-files -z "$@" | xargs -0 grep $flags "$pattern"