From: Denton Liu <liu.denton@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: "Git Mailing List" <git@vger.kernel.org>,
"SZEDER Gábor" <szeder.dev@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH 4/5] git-completion.bash: consolidate cases in _git_stash()
Date: Tue, 20 Apr 2021 21:03:40 -0700 [thread overview]
Message-ID: <YH+kHGLBLpPVW+88@generichostname> (raw)
In-Reply-To: <877dkx44ma.fsf@evledraar.gmail.com>
Hi Ævar,
On Tue, Apr 20, 2021 at 12:44:45PM +0200, Ævar Arnfjörð Bjarmason wrote:
>
> On Tue, Apr 20 2021, Denton Liu wrote:
>
> > The $subcommand case statement in _git_stash() is quite repetitive.
> > Consolidate the cases together into one catch-all case to reduce the
> > repetition.
> >
> > Signed-off-by: Denton Liu <liu.denton@gmail.com>
> > ---
> > contrib/completion/git-completion.bash | 21 ++-------------------
> > 1 file changed, 2 insertions(+), 19 deletions(-)
> >
> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> > index 30c9a97616..7bce9a0112 100644
> > --- a/contrib/completion/git-completion.bash
> > +++ b/contrib/completion/git-completion.bash
> > @@ -3032,21 +3032,6 @@ _git_stash ()
> > fi
> >
> > case "$subcommand,$cur" in
> > - push,--*)
> > - __gitcomp_builtin stash_push
> > - ;;
> > - save,--*)
> > - __gitcomp_builtin stash_save
> > - ;;
> > - pop,--*)
> > - __gitcomp_builtin stash_pop
> > - ;;
> > - apply,--*)
> > - __gitcomp_builtin stash_apply
> > - ;;
> > - drop,--*)
> > - __gitcomp_builtin stash_drop
> > - ;;
> > list,--*)
> > # NEEDSWORK: can we somehow unify this with the options in _git_log() and _git_show()
> > __gitcomp_builtin stash_list "$__git_log_common_options $__git_diff_common_options"
> > @@ -3054,8 +3039,8 @@ _git_stash ()
> > show,--*)
> > __gitcomp_builtin stash_show "$__git_diff_common_options"
> > ;;
> > - branch,--*)
> > - __gitcomp_builtin stash_branch
> > + *,--*)
> > + __gitcomp_builtin "stash_$subcommand"
> > ;;
> > branch,*)
> > if [ $cword -eq $((__git_cmd_idx+2)) ]; then
> > @@ -3069,8 +3054,6 @@ _git_stash ()
> > __gitcomp_nl "$(__git stash list \
> > | sed -n -e 's/:.*//p')"
> > ;;
> > - *)
> > - ;;
> > esac
> > }
>
> One might think that this introduces a logic error in "git stash
> doesnotexist" now dispatching to a non-existing "stash_doesnotexist" or
> something, bu tI see that earlier (omitted from context) in the function
> there's an exhaustive lit of push/save/pop etc. which guards against
> this, is is that correct?
Yep, that's exactly correct.
next prev parent reply other threads:[~2021-04-21 4:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 9:19 [PATCH 0/5] git-completion.bash: fixes on top of 'dl/complete-stash' Denton Liu
2021-04-20 9:19 ` [PATCH 1/5] git-completion.bash: separate some commands onto their own line Denton Liu
2021-04-20 9:19 ` [PATCH 2/5] git-completion.bash: rename to $__git_cmd_idx Denton Liu
2021-04-20 20:50 ` Junio C Hamano
2021-04-20 21:14 ` SZEDER Gábor
2021-04-20 22:31 ` Junio C Hamano
2021-04-20 9:19 ` [PATCH 3/5] git-completion.bash: use $__git_cmd_idx in more places Denton Liu
2021-04-20 9:19 ` [PATCH 4/5] git-completion.bash: consolidate cases in _git_stash() Denton Liu
2021-04-20 10:44 ` Ævar Arnfjörð Bjarmason
2021-04-21 4:03 ` Denton Liu [this message]
2021-04-20 9:19 ` [PATCH 5/5] git-completion.bash: consolidate no-subcommand case for _git_stash() Denton Liu
2021-04-20 21:10 ` Junio C Hamano
2021-04-21 4:08 ` Denton Liu
2021-04-22 10:00 ` [PATCH v2 0/4] git-completion.bash: fixes on top of 'dl/complete-stash' Denton Liu
2021-04-22 10:00 ` [PATCH v2 1/4] git-completion.bash: separate some commands onto their own line Denton Liu
2021-04-22 10:00 ` [PATCH v2 2/4] git-completion.bash: rename to $__git_cmd_idx Denton Liu
2021-04-22 10:00 ` [PATCH v2 3/4] git-completion.bash: use $__git_cmd_idx in more places Denton Liu
2021-04-22 10:00 ` [PATCH v2 4/4] git-completion.bash: consolidate cases in _git_stash() Denton Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YH+kHGLBLpPVW+88@generichostname \
--to=liu.denton@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).