@matheusbsbs / matheus-bagliano / commits / 6c44b6406b
Fork 0

bash-completion: Fix __git_ps1 to work with "set -u"

Define several variables in __git_ps1 to avoid errors under "set -u" semantics. __git_ps1 seems to have been missed when the rest of the file was fixed in 25a31f8. Signed-off-by: Andrew Sayers <andrew-git@pileofstuff.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Andrew Sayers committed Jun 17, 2010 at 22:32 UTC 6c44b6406bc9093945aa030f33c06ecda47ba7f5
1 file changed +7 -7
contrib/completion/git-completion.bash
+7 -7
@@ -84,8 +84,8 @@ __git_ps1 ()
84 {
85 local g="$(__gitdir)"
86 if [ -n "$g" ]; then
87 - local r
88 - local b
87 + local r=""
88 + local b=""
89 if [ -f "$g/rebase-merge/interactive" ]; then
90 r="|REBASE-i"
91 b="$(cat "$g/rebase-merge/head-name")"
@@ -127,11 +127,11 @@ __git_ps1 ()
127 }
128 fi
129
130 - local w
131 - local i
132 - local s
133 - local u
134 - local c
130 + local w=""
131 + local i=""
132 + local s=""
133 + local u=""
134 + local c=""
135
136 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
137 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then