summaryrefslogtreecommitdiff
path: root/git-grep.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git-grep.sh')
-rwxr-xr-xgit-grep.sh20
1 files changed, 20 insertions, 0 deletions
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"