]> git.ipfire.org Git - thirdparty/git.git/blame - git-grep.sh
Documentation nitpicking
[thirdparty/git.git] / git-grep.sh
CommitLineData
f22cc3fc 1#!/bin/sh
5d9d831a
LT
2#
3# Copyright (c) Linus Torvalds, 2005
4#
5
6pattern=
7flags=()
8git_flags=()
9while : ; do
10 case "$1" in
11 --cached|--deleted|--others|--killed|\
12 --ignored|--exclude=*|\
13 --exclude-from=*|\--exclude-per-directory=*)
14 git_flags=("${git_flags[@]}" "$1")
15 ;;
16 -e)
17 pattern="$2"
18 shift
19 ;;
20 -A|-B|-C|-D|-d|-f|-m)
21 flags=("${flags[@]}" "$1" "$2")
22 shift
23 ;;
24 --)
25 # The rest are git-ls-files paths (or flags)
26 shift
27 break
28 ;;
29 -*)
30 flags=("${flags[@]}" "$1")
31 ;;
32 *)
33 if [ -z "$pattern" ]; then
34 pattern="$1"
35 shift
36 fi
37 break
38 ;;
39 esac
40 shift
f22cc3fc 41done
5d9d831a 42git-ls-files -z "${git_flags[@]}" "$@" |
c9fc748f 43 xargs -0 grep "${flags[@]}" -e "$pattern"