Skip to content

Commit 6c44b64

Browse files
Andrew Sayersgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 45a0ee1 commit 6c44b64

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

contrib/completion/git-completion.bash

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ __git_ps1 ()
8484
{
8585
local g="$(__gitdir)"
8686
if [ -n "$g" ]; then
87-
local r
88-
local b
87+
local r=""
88+
local b=""
8989
if [ -f "$g/rebase-merge/interactive" ]; then
9090
r="|REBASE-i"
9191
b="$(cat "$g/rebase-merge/head-name")"
@@ -127,11 +127,11 @@ __git_ps1 ()
127127
}
128128
fi
129129

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=""
135135

136136
if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
137137
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then

0 commit comments

Comments
 (0)