grep docs: --cached and <tree>... are incompatible
[gitweb.git] / git-sh-setup.sh
index 99cceeb858dcd2c83a040b0dd3117744e177e316..d56426dd396190a07de7d661cd22fb284b759ca8 100755 (executable)
@@ -107,25 +107,24 @@ git_editor() {
        eval "$GIT_EDITOR" '"$@"'
 }
 
+sane_grep () {
+       GREP_OPTIONS= LC_ALL=C grep "$@"
+}
+
+sane_egrep () {
+       GREP_OPTIONS= LC_ALL=C egrep "$@"
+}
+
 is_bare_repository () {
        git rev-parse --is-bare-repository
 }
 
 cd_to_toplevel () {
-       cdup=$(git rev-parse --show-cdup)
-       if test ! -z "$cdup"
-       then
-               # The "-P" option says to follow "physical" directory
-               # structure instead of following symbolic links.  When cdup is
-               # "../", this means following the ".." entry in the current
-               # directory instead textually removing a symlink path element
-               # from the PWD shell variable.  The "-P" behavior is more
-               # consistent with the C-style chdir used by most of Git.
-               cd -P "$cdup" || {
-                       echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
-                       exit 1
-               }
-       fi
+       cdup=$(git rev-parse --show-toplevel) &&
+       cd "$cdup" || {
+               echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
+               exit 1
+       }
 }
 
 require_work_tree () {