6 echo " $0 search_pattern [-- <pathspec> ]"
7 echo " $0 search_pattern replacement [-- <pathspec> ]"
9 echo "Pattern should be a basic regexp as accepted by grep and sed."
10 echo "For information on pathspec syntax, see git documentation."
16 if [ "$1" == "--" ]; then
18 elif [ "$#" -eq 1 ] ||
[ "$2" == "--" ]; then
21 git
grep -I -n "$pattern" "$@"
22 elif [ "$#" -eq 2 ] ||
[ "$3" == "--" ]; then
24 if ( git status
--porcelain |
grep '^.[^ ]' ); then
25 echo "You have unstaged changes in your tree."
26 echo "Either stage them with 'git add', commit them,"
27 echo "or discard them with 'git checkout -- .'"
35 git
grep -I -l "$pattern" "$@" |
xargs sed -i "s/$pattern/$replacement/g"