All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Felipe Contreras <felipec@infradead.org>
Cc: git@vger.kernel.org,
	"Felipe Contreras" <felipe.contreras@gmail.com>,
	"Ted Pavlic" <ted@tedpavlic.com>,
	"SZEDER Gábor" <szeder@ira.uka.de>,
	"Shawn O. Pearce" <spearce@spearce.org>
Subject: Re: [PATCH v2 3/4] completion: cleanup __gitcomp*
Date: Mon, 30 Jan 2012 11:50:04 -0600	[thread overview]
Message-ID: <20120130175004.GG10618@burratino> (raw)
In-Reply-To: <1327944197-6379-4-git-send-email-felipec@infradead.org>

Felipe Contreras wrote:

> I don't know why there's so much code; these functions don't seem to be
> doing much:

Unless you mean "This patch has had inadequate review and I don't
understand the code I'm patching, so do not trust it", please drop
this commentary or place it after the three dashes.

>  * no need to check $#, ${3:-$cur} is much easier
>  * __gitcomp_nl doesn't seem to using the initial IFS
>
> This makes the code much simpler.
>
> Eventually it would be nice to wrap everything that touches compgen and
> COMPREPLY in one function for the zsh wrapper.
>
> Comments by Jonathan Nieder.

I don't want this acknowledgement.  Who should care that I commented
on something?

> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  contrib/completion/git-completion.bash |   20 +++-----------------
>  1 files changed, 3 insertions(+), 17 deletions(-)

This diffstat tells me more of what I wanted to know about the patch
than the description did.

I imagine it would have been enough to say something along the lines of
"The __gitcomp and __gitcomp_nl functions are unnecessarily verbose.
__gitcomp_nl sets IFS to " \t\n" unnecessarily before setting it to "\n"
by mistake.  Both functions use 'if' statements to read parameters
with defaults, where the ${parameter:-default} idiom would be just as
clear.  By fixing these, we can make each function almost a one-liner."

By the way, the subject ("clean up __gitcomp*") tells me almost as
little as something like "fix __gitcomp*".  A person reading the
shortlog would like to know _how_ you are fixing it, or what the
impact of the change will be --- e.g., something like "simplify
__gitcomp and __gitcomp_nl" would be clearer.

[...]
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
[...]
> @@ -524,18 +520,8 @@ __gitcomp ()
>  #    appended.
>  __gitcomp_nl ()
>  {
> -	local s=$'\n' IFS=' '$'\t'$'\n'
> -	local cur_="$cur" suffix=" "
> -
> -	if [ $# -gt 2 ]; then
> -		cur_="$3"
> -		if [ $# -gt 3 ]; then
> -			suffix="$4"
> -		fi
> -	fi
> -
> -	IFS=$s
> -	COMPREPLY=($(compgen -P "${2-}" -S "$suffix" -W "$1" -- "$cur_"))
> +	local IFS=$'\n'
> +	COMPREPLY=($(compgen -P "${2-}" -S "${4:- }" -W "$1" -- "${3:-$cur}"))

This loses the nice name $suffix for the -S argument.  Not a problem,
just noticing.

  parent reply	other threads:[~2012-01-30 17:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 17:23 [PATCH 0/4] completion: trivial cleanups Felipe Contreras
2012-01-30 17:23 ` [PATCH v2 2/4] completion: remove unused code Felipe Contreras
     [not found] ` <1327944197-6379-2-git-send-email-felipec@infradead.org>
2012-01-30 17:34   ` [PATCH v2 1/4] completion: simplify __git_remotes Jonathan Nieder
2012-01-30 18:27     ` Junio C Hamano
     [not found] ` <1327944197-6379-4-git-send-email-felipec@infradead.org>
2012-01-30 17:50   ` Jonathan Nieder [this message]
2012-01-30 19:03     ` [PATCH v2 3/4] completion: cleanup __gitcomp* Junio C Hamano
2012-01-30 21:25       ` Junio C Hamano
2012-01-31  0:15     ` SZEDER Gábor
2012-01-31  0:25       ` Jonathan Nieder
     [not found] ` <1327944197-6379-5-git-send-email-felipec@infradead.org>
2012-01-30 17:53   ` [PATCH v2 4/4] completion: be nicer with zsh Jonathan Nieder
2012-01-30 18:10     ` Felipe Contreras
2012-01-30 18:25       ` Jonathan Nieder
2012-01-30 18:56         ` Felipe Contreras
2012-01-30 19:03           ` Jonathan Nieder
2012-01-30 19:09         ` Junio C Hamano
2012-01-30 19:22           ` Felipe Contreras
2012-01-30 19:28             ` Jonathan Nieder

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=20120130175004.GG10618@burratino \
    --to=jrnieder@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=felipec@infradead.org \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    --cc=szeder@ira.uka.de \
    --cc=ted@tedpavlic.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 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.