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."
17 if [ "$1" = "--" ]; then
19 elif [ "$#" -eq 1 ] ||
[ "$2" = "--" ]; then
22 git
grep -I -n "$pattern" "$@"
23 elif [ "$#" -eq 2 ] ||
[ "$3" = "--" ]; then
25 if ( git status
--porcelain |
grep '^.[^ ]' ); then
26 echo "You have unstaged changes in your tree."
27 echo "Either stage them with 'git add', commit them,"
28 echo "or discard them with 'git checkout -- .'"
36 git
grep -I -l "$pattern" "$@" |
xargs sed -i "s/$pattern/$replacement/g"