]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-completion.bash: extract from else in _git_stash()
authorDenton Liu <liu.denton@gmail.com>
Wed, 24 Mar 2021 08:36:28 +0000 (01:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Mar 2021 17:05:47 +0000 (10:05 -0700)
To save a level of indentation, perform an early return in the "if" arm
so we can move the "else" code out of the block.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index a2f1b5e9164560e6be032da55e9b725ccb783884..8d4d8cc0feee10231a58eae0c1d69a561c924250 100644 (file)
@@ -3035,44 +3035,45 @@ _git_stash ()
                        fi
                        ;;
                esac
-       else
-               case "$subcommand,$cur" in
-               push,--*)
-                       __gitcomp "$save_opts --message"
-                       ;;
-               save,--*)
-                       __gitcomp "$save_opts"
-                       ;;
-               apply,--*|pop,--*)
-                       __gitcomp "--index --quiet"
-                       ;;
-               drop,--*)
-                       __gitcomp "--quiet"
-                       ;;
-               list,--*)
-                       __gitcomp "--name-status --oneline --patch-with-stat"
-                       ;;
-               show,--*)
-                       __gitcomp "$__git_diff_common_options"
-                       ;;
-               branch,--*)
-                       ;;
-               branch,*)
-                       if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
-                               __git_complete_refs
-                       else
-                               __gitcomp_nl "$(__git stash list \
-                                               | sed -n -e 's/:.*//p')"
-                       fi
-                       ;;
-               show,*|apply,*|drop,*|pop,*)
+               return
+       fi
+
+       case "$subcommand,$cur" in
+       push,--*)
+               __gitcomp "$save_opts --message"
+               ;;
+       save,--*)
+               __gitcomp "$save_opts"
+               ;;
+       apply,--*|pop,--*)
+               __gitcomp "--index --quiet"
+               ;;
+       drop,--*)
+               __gitcomp "--quiet"
+               ;;
+       list,--*)
+               __gitcomp "--name-status --oneline --patch-with-stat"
+               ;;
+       show,--*)
+               __gitcomp "$__git_diff_common_options"
+               ;;
+       branch,--*)
+               ;;
+       branch,*)
+               if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
+                       __git_complete_refs
+               else
                        __gitcomp_nl "$(__git stash list \
                                        | sed -n -e 's/:.*//p')"
-                       ;;
-               *)
-                       ;;
-               esac
-       fi
+               fi
+               ;;
+       show,*|apply,*|drop,*|pop,*)
+               __gitcomp_nl "$(__git stash list \
+                               | sed -n -e 's/:.*//p')"
+               ;;
+       *)
+               ;;
+       esac
 }
 
 _git_submodule ()