git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: "SZEDER Gábor" <szeder@ira.uka.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] bash: __git_find_subcommand function
Date: Fri, 7 Mar 2008 21:23:42 -0500	[thread overview]
Message-ID: <20080308022342.GY8410@spearce.org> (raw)
In-Reply-To: <1204815512-18128-1-git-send-email-szeder@ira.uka.de>

SZEDER Gbor <szeder@ira.uka.de> wrote:
> This enables us to remove code duplications from completion
> functions for commands having subcommands.
> 
> Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
> ---
> This function does not return the index of the subcommand found on the
> command line, which was in the $c variable previously.  However, $c was
> only used in if statements, like:
> 	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
> 		__gitcomp "cmd1 cmd2 cmd3"
> 	fi
> To my understanding the only(?) purpose of those if statements was to
> prevent subcommands appearing again on the list of possible completions,
> when there was one already on the command line.  But [ -z $command ] is
> sufficient to detect those cases, so we can actually omit
> [ $c -eq $COMP_CWORD ].  Is it right, or am I missing something?

Yup, you understood it correctly.  You found a cluster of "copy and
paste programming" and I am happy to see it cleaned up.  Thanks.

-- 
Shawn.

  reply	other threads:[~2008-03-08  2:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-06 14:58 [PATCH] bash: __git_find_subcommand function SZEDER Gábor
2008-03-08  2:23 ` Shawn O. Pearce [this message]
2008-03-10 14:51   ` SZEDER Gábor

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080308022342.GY8410@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=szeder@ira.uka.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).