7 echo " $0 search_pattern [-- <pathspec> ]"
8 echo " $0 search_pattern replacement [-- <pathspec> ]"
10 echo "Pattern should be a basic regexp as accepted by grep and sed."
11 echo "For information on pathspec syntax, see git documentation."
18 if ( git status
--porcelain |
grep '^.[^ ]' ); then
19 echo "You have unstaged changes in your tree."
20 echo "Either stage them with 'git add', commit them,"
21 echo "or discard them with 'git checkout -- .'"
28 # Some shells have shoddy handling of backslashes in echo.
29 printf '%s\n' "$1" |
sed 's/\([^\\]\)\//\1\\\//g'
32 if [ "$1" = "--" ]; then
34 elif [ "$1" = "-d" ]; then
37 pattern
=`_slashify "$2"`
40 git
grep -I -l "$pattern" "$@" |
xargs sed -i "/$pattern/d"
42 elif [ "$#" -eq 1 ] ||
[ "$2" = "--" ]; then
43 pattern
=`_slashify "$1"`
45 git
grep -I -n "$pattern" "$@"
46 elif [ "$#" -eq 2 ] ||
[ "$3" = "--" ]; then
49 pattern
=`_slashify "$1"`
50 replacement
=`_slashify "$2"`
53 git
grep -I -l "$pattern" "$@" |
xargs sed -i "s/$pattern/$replacement/g"