Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #27 from phatblat/pull/suppress-ps1-errors

Suppress dirty marker and errors building PS1 when outside a repo
  • Loading branch information...
commit 023079f884e63cef088abd2c3f35871dfadfdd6a 2 parents 7b82d95 + 010de87
@rtomayko authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 git-sh.bash
View
9 git-sh.bash
@@ -183,7 +183,10 @@ ANSI_RESET="\001$(git config --get-color "" "reset")\002"
# detect whether the tree is in a dirty state.
_git_dirty() {
- local dirty_marker="`git config gitsh.dirty || echo ' *'`"
+ if ! git rev-parse --verify HEAD >/dev/null 2>&1; then
+ return 0
+ fi
+ local dirty_marker="`git config gitsh.dirty 2>/dev/null || echo ' *'`"
if ! git diff --quiet 2>/dev/null ; then
_git_apply_color "$dirty_marker" "color.sh.dirty" "red"
@@ -199,7 +202,7 @@ _git_dirty_stash() {
if ! git rev-parse --verify refs/stash >/dev/null 2>&1; then
return 0
fi
- local dirty_stash_marker="`git config gitsh.dirty-stash || echo ' $'`"
+ local dirty_stash_marker="`git config gitsh.dirty-stash 2>/dev/null || echo ' $'`"
_git_apply_color "$dirty_stash_marker" "color.sh.dirty-stash" "red"
}
@@ -222,7 +225,7 @@ _git_workdir() {
# detect if the repository is in a special state (rebase or merge)
_git_repo_state() {
- local git_dir="$(git rev-parse --show-cdup).git"
+ local git_dir="$(git rev-parse --show-cdup 2>/dev/null).git"
if test -d "$git_dir/rebase-merge" -o -d "$git_dir/rebase-apply"; then
local state_marker="(rebase)"
elif test -f "$git_dir/MERGE_HEAD"; then
Please sign in to comment.
Something went wrong with that request. Please try again.