aboutsummaryrefslogtreecommitdiff
path: root/contrib/completion
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-12-28 14:08:45 -0800
committerJunio C Hamano <gitster@pobox.com>2017-12-28 14:08:45 -0800
commit5abbdbbd9bd32aaae0e11d078b0151f7a7e3d20d (patch)
tree41a12d0f47ebf86c91492097bf7a3ef05d4db0ec /contrib/completion
parent1f24cad852cdfad871182e53a2b7f7d392ac7c66 (diff)
parent041fe8fc83770f95b09db4aa9d9b3783789eab08 (diff)
downloadgit-5abbdbbd9bd32aaae0e11d078b0151f7a7e3d20d.tar.gz
git-5abbdbbd9bd32aaae0e11d078b0151f7a7e3d20d.tar.xz
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
Diffstat (limited to 'contrib/completion')
-rw-r--r--contrib/completion/git-prompt.sh7
1 files changed, 4 insertions, 3 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index c6cbef38c..983e419d2 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -278,11 +278,12 @@ __git_ps1_colorize_gitstring ()
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 ()
{
- local f="$1"
- shift
- test -r "$f" && read "$@" <"$f"
+ test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
}
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)