Merge branch 'ra/prompt-eread-fix'

Update the shell prompt script (in contrib/) to strip trailing CR
from strings read from various "state" files.

* ra/prompt-eread-fix:
  git-prompt: fix reading files with windows line endings
  git-prompt: make __git_eread intended use explicit
This commit is contained in:
Junio C Hamano 2017-12-28 14:08:45 -08:00
commit 5abbdbbd9b

View File

@ -278,11 +278,12 @@ __git_ps1_colorize_gitstring ()
r="$c_clear$r" r="$c_clear$r"
} }
# Helper function to read the first line of a file into a variable.
# __git_eread requires 2 arguments, the file path and the name of the
# variable, in that order.
__git_eread () __git_eread ()
{ {
local f="$1" test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
shift
test -r "$f" && read "$@" <"$f"
} }
# __git_ps1 accepts 0 or 1 arguments (i.e., format string) # __git_ps1 accepts 0 or 1 arguments (i.e., format string)