blob: 2ed8e955d6c44da7bd15342aac64de997f0f4bf4 [file] [log] [blame]
Linus Torvaldsf22cc3f2005-09-12 12:06:10 -07001#!/bin/sh
Linus Torvalds5d9d8312005-09-12 16:46:53 -07002#
3# Copyright (c) Linus Torvalds, 2005
4#
5
freku045@student.liu.se806f36d2005-12-13 23:30:31 +01006USAGE='<option>... <pattern> <path>...'
7SUBDIRECTORY_OK='Yes'
8. git-sh-setup
9
Linus Torvalds5d9d8312005-09-12 16:46:53 -070010pattern=
11flags=()
12git_flags=()
13while : ; do
14 case "$1" in
15 --cached|--deleted|--others|--killed|\
16 --ignored|--exclude=*|\
17 --exclude-from=*|\--exclude-per-directory=*)
18 git_flags=("${git_flags[@]}" "$1")
19 ;;
20 -e)
21 pattern="$2"
22 shift
23 ;;
24 -A|-B|-C|-D|-d|-f|-m)
25 flags=("${flags[@]}" "$1" "$2")
26 shift
27 ;;
28 --)
29 # The rest are git-ls-files paths (or flags)
30 shift
31 break
32 ;;
33 -*)
34 flags=("${flags[@]}" "$1")
35 ;;
36 *)
37 if [ -z "$pattern" ]; then
38 pattern="$1"
39 shift
40 fi
41 break
42 ;;
43 esac
44 shift
Linus Torvaldsf22cc3f2005-09-12 12:06:10 -070045done
Linus Torvaldsc0c35d52005-11-16 09:38:46 -080046[ "$pattern" ] || {
freku045@student.liu.se806f36d2005-12-13 23:30:31 +010047 usage
Linus Torvaldsc0c35d52005-11-16 09:38:46 -080048}
Linus Torvalds5d9d8312005-09-12 16:46:53 -070049git-ls-files -z "${git_flags[@]}" "$@" |
Junio C Hamanoc9fc7482005-09-24 15:09:48 -070050 xargs -0 grep "${flags[@]}" -e "$pattern"