summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-04-18 11:17:22 -0700
committerJunio C Hamano <gitster@pobox.com>2014-04-18 11:17:23 -0700
commit427ed406cda52f07b36dd8fe69c8c7ad6e6ae39a (patch)
treea15236415fb167fa1e4ba3d25531610f88da2de8 /contrib
parent3f0c02a1c018ddaced5c97b58f550b2ad17dd0a9 (diff)
parent59d3924fbb300ebfe05f9079bcfe29d0a3f30661 (diff)
downloadgit-427ed406cda52f07b36dd8fe69c8c7ad6e6ae39a.tar.gz
Merge branch 'fc/prompt-zsh-read-from-file'
* fc/prompt-zsh-read-from-file: prompt: fix missing file errors in zsh
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/git-prompt.sh21
1 files changed, 14 insertions, 7 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 7b732d2aeb..54489080f8 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -259,6 +259,13 @@ __git_ps1_colorize_gitstring ()
r="$c_clear$r"
}
+eread ()
+{
+ f="$1"
+ shift
+ test -r "$f" && read "$@" <"$f"
+}
+
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# when called from PS1 using command substitution
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
@@ -321,9 +328,9 @@ __git_ps1 ()
local step=""
local total=""
if [ -d "$g/rebase-merge" ]; then
- read b 2>/dev/null <"$g/rebase-merge/head-name"
- read step 2>/dev/null <"$g/rebase-merge/msgnum"
- read total 2>/dev/null <"$g/rebase-merge/end"
+ eread "$g/rebase-merge/head-name" b
+ eread "$g/rebase-merge/msgnum" step
+ eread "$g/rebase-merge/end" total
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
else
@@ -331,10 +338,10 @@ __git_ps1 ()
fi
else
if [ -d "$g/rebase-apply" ]; then
- read step 2>/dev/null <"$g/rebase-apply/next"
- read total 2>/dev/null <"$g/rebase-apply/last"
+ eread "$g/rebase-apply/next" step
+ eread "$g/rebase-apply/last" total
if [ -f "$g/rebase-apply/rebasing" ]; then
- read b 2>/dev/null <"$g/rebase-apply/head-name"
+ eread "$g/rebase-apply/head-name" b
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
@@ -358,7 +365,7 @@ __git_ps1 ()
b="$(git symbolic-ref HEAD 2>/dev/null)"
else
local head=""
- if ! read head 2>/dev/null <"$g/HEAD"; then
+ if ! eread "$g/HEAD" head; then
if [ $pcmode = yes ]; then
PS1="$ps1pc_start$ps1pc_end"
fi