Skip to content

Commit b2b7a54

Browse files
committed
Merge branch 'vs/completion-with-set-u' into master
The command line completion support (in contrib/) used to be prepared to work with "set -u" but recent changes got a bit more sloppy. This has been corrected. * vs/completion-with-set-u: completion: nounset mode fixes
2 parents 8251695 + c2dbcd2 commit b2b7a54

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

contrib/completion/git-completion.bash

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ esac
5050
# variable.
5151
__git_find_repo_path ()
5252
{
53-
if [ -n "$__git_repo_path" ]; then
53+
if [ -n "${__git_repo_path-}" ]; then
5454
# we already know where it is
5555
return
5656
fi
@@ -404,12 +404,12 @@ __gitcomp_builtin ()
404404
# spaces must be replaced with underscore for multi-word
405405
# commands, e.g. "git remote add" becomes remote_add.
406406
local cmd="$1"
407-
local incl="$2"
408-
local excl="$3"
407+
local incl="${2-}"
408+
local excl="${3-}"
409409

410410
local var=__gitcomp_builtin_"${cmd/-/_}"
411411
local options
412-
eval "options=\$$var"
412+
eval "options=\${$var-}"
413413

414414
if [ -z "$options" ]; then
415415
# leading and trailing spaces are significant to make
@@ -801,7 +801,7 @@ __git_refs ()
801801
# --remote is only compatible with --mode=refs.
802802
__git_complete_refs ()
803803
{
804-
local remote dwim pfx cur_="$cur" sfx=" " mode="refs"
804+
local remote= dwim= pfx= cur_="$cur" sfx=" " mode="refs"
805805

806806
while test $# != 0; do
807807
case "$1" in
@@ -1152,7 +1152,7 @@ __git_find_on_cmdline ()
11521152
while [ $c -lt $cword ]; do
11531153
for word in $wordlist; do
11541154
if [ "$word" = "${words[c]}" ]; then
1155-
if [ -n "$show_idx" ]; then
1155+
if [ -n "${show_idx-}" ]; then
11561156
echo "$c $word"
11571157
else
11581158
echo "$word"
@@ -1468,7 +1468,7 @@ __git_checkout_default_dwim_mode ()
14681468
{
14691469
local last_option dwim_opt="--dwim"
14701470

1471-
if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ]; then
1471+
if [ "${GIT_COMPLETION_CHECKOUT_NO_GUESS-}" = "1" ]; then
14721472
dwim_opt=""
14731473
fi
14741474

@@ -3350,7 +3350,7 @@ __git_main ()
33503350
((c++))
33513351
done
33523352

3353-
if [ -z "$command" ]; then
3353+
if [ -z "${command-}" ]; then
33543354
case "$prev" in
33553355
--git-dir|-C|--work-tree)
33563356
# these need a path argument, let's fall back to
@@ -3385,7 +3385,7 @@ __git_main ()
33853385
"
33863386
;;
33873387
*)
3388-
if test -n "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
3388+
if test -n "${GIT_TESTING_PORCELAIN_COMMAND_LIST-}"
33893389
then
33903390
__gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
33913391
else

0 commit comments

Comments
 (0)