X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=git-sh-setup.sh;h=6131670860514c215a6b9b7417dd05c3124e81b4;hb=refs%2Ftags%2Fv1.7.0.8;hp=dcf9d0a31030ce4b6a7e7f2268ed8d25fdb57322;hpb=b7380fa7a9adb52860eef7e8885fb8bc179beae1;p=git.git diff --git a/git-sh-setup.sh b/git-sh-setup.sh index dcf9d0a31..613167086 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -107,6 +107,19 @@ git_editor() { eval "$GIT_EDITOR" '"$@"' } +git_pager() { + if test -t 1 + then + GIT_PAGER=$(git var GIT_PAGER) + else + GIT_PAGER=cat + fi + : ${LESS=-FRSX} + export LESS + + eval "$GIT_PAGER" '"$@"' +} + sane_grep () { GREP_OPTIONS= LC_ALL=C grep "$@" } @@ -120,20 +133,11 @@ 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 () { @@ -168,6 +172,13 @@ get_author_ident_from_commit () { LANG=C LC_ALL=C sed -ne "$pick_author_script" } +# Clear repo-local GIT_* environment variables. Useful when switching to +# another repository (e.g. when entering a submodule). See also the env +# list in git_connect() +clear_local_git_env() { + unset $(git rev-parse --local-env-vars) +} + # Make sure we are in a valid repository of a vintage we understand, # if we require to be in a git repository. if test -z "$NONGIT_OK"