From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Jeff King <peff@peff.net>
Subject: Re: [PATCH v3 2/2] completion: bash: check for alias loop
Date: Thu, 12 Nov 2020 11:02:04 +0100 [thread overview]
Message-ID: <20201112100204.GC4270@szeder.dev> (raw)
In-Reply-To: <20201110020343.548848-3-felipe.contreras@gmail.com>
On Mon, Nov 09, 2020 at 08:03:43PM -0600, Felipe Contreras wrote:
> We don't want to be stuck in an endless cycle.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
> contrib/completion/git-completion.bash | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index eb00d9ba22..ce0dc1e0f8 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1121,11 +1121,16 @@ __git_pretty_aliases ()
> # __git_aliased_command requires 1 argument
> __git_aliased_command ()
> {
> - local cur=$1 last word cmdline
> + local cur=$1 list word cmdline
>
> while [[ -n "$cur" ]]; do
> + if [[ "$list" == *"$cur "* ]]; then
I suspect the right hand side should be *" $cur "* ...
> + # loop detected
> + return
> + fi
> +
> cmdline=$(__git config --get "alias.$cur")
> - last=$cur
> + list="$cur $list"
... and this should be list=" $cur $list", because otherwise a partial
match is possible and would be mistaken for a loop (though I didn't
actually test whether that's indeed the case).
> cur=
>
> for word in $cmdline; do
> @@ -1149,7 +1154,7 @@ __git_aliased_command ()
> done
> done
>
> - cur=$last
> + cur="${list%% *}"
> if [[ "$cur" != "$1" ]]; then
> echo "$cur"
> fi
> --
> 2.29.2
>
next prev parent reply other threads:[~2020-11-12 10:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 2:03 [PATCH v3 0/2] completion: bash: support for recursive aliases Felipe Contreras
2020-11-10 2:03 ` [PATCH v3 1/2] completion: bash: support " Felipe Contreras
2020-11-10 2:03 ` [PATCH v3 2/2] completion: bash: check for alias loop Felipe Contreras
2020-11-12 10:02 ` SZEDER Gábor [this message]
2020-11-12 17:20 ` Junio C Hamano
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=20201112100204.GC4270@szeder.dev \
--to=szeder.dev@gmail.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.