In case the command fails.

Signed-off-by: Felipe Contreras <felipe.contre...@gmail.com>
---
 contrib/completion/git-completion.bash | 4 +++-
 t/t9902-completion.sh                  | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 922ba5f925..91b87eb558 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -936,6 +936,7 @@ __git_list_merge_strategies ()
        }'
 }
 
+__git_merge_strategies_default='octopus ours recursive resolve subtree'
 __git_merge_strategies=
 # 'git merge -s help' (and thus detection of the merge strategy
 # list) fails, unfortunately, if run outside of any git working
@@ -945,7 +946,8 @@ __git_merge_strategies=
 __git_compute_merge_strategies ()
 {
        test -n "$__git_merge_strategies" ||
-       __git_merge_strategies=$(__git_list_merge_strategies)
+       { __git_merge_strategies=$(__git_list_merge_strategies);
+               
__git_merge_strategies="${__git_merge_strategies:-__git_merge_strategies_default}";
 }
 }
 
 __git_merge_strategy_options="ours theirs subtree subtree= patience
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 14598bfbec..f4453ce70d 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1722,7 +1722,7 @@ test_expect_success 'sourcing the completion script 
clears cached commands' '
        verbose test -z "$__git_all_commands"
 '
 
-test_expect_failure 'sourcing the completion script clears cached merge 
strategies' '
+test_expect_success 'sourcing the completion script clears cached merge 
strategies' '
        offgit &&
        GIT_TEST_GETTEXT_POISON= &&
        __git_compute_merge_strategies &&
-- 
2.22.0

Reply via email to