From: Junio C Hamano <gitster@pobox•com>
To: Ramkumar Ramachandra <artagnon@gmail•com>
Cc: Git List <git@vger•kernel.org>,
Felipe Contreras <felipe.contreras@gmail•com>
Subject: Re: [PATCH 2/4] completion: introduce __gitcomp_2 ()
Date: Thu, 02 Jan 2014 15:47:59 -0800 [thread overview]
Message-ID: <xmqqeh4qndxs.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1388415138-11011-3-git-send-email-artagnon@gmail.com> (Ramkumar Ramachandra's message of "Mon, 30 Dec 2013 20:22:16 +0530")
Ramkumar Ramachandra <artagnon@gmail•com> writes:
> There are situations where two classes of completions possible. For
> example
>
> branch.<TAB>
>
> should try to complete
>
> branch.master.
> branch.autosetupmerge
> branch.autosetuprebase
>
> The first candidate has the suffix ".", and the second/ third candidates
> have the suffix " ". To facilitate completions of this kind, create a
> variation of __gitcomp_nl () that accepts two sets of arguments and two
> independent suffixes.
That sounds like a reasonable issue to address, but I do not quite
get why you need a new helper to do this.
If the original only knows to throw "branch." + branch names +
trailing dot into COMPREPLY[] and does so by calling gitcomp_nl,
isn't it the matter of making another call to gitcomp_nl just after
the existing call to stuff branch.autosetup* with trailing SP to
append them to COMPREPLY[]?
Ahh, is that because the eventual call to __gitcompadd() starts the
iteration starting from zero, essentially forbidding you to
incrementally adding to COMPREPLY[] from multiple callers, even
though it is called comp "add" not "replace with this single thing"?
What I am wondering is if a cleaner solution that can be reused by
later needs that may have more than two data sources (or more than
two suffixes) might be to create a variant of __gitcomp_nl that does
not clear existing entries in COMPREPLY[] array, add a helper to
clear the array, which would make the existing one to:
__gitcomp_nl () {
__gitcomp_clear
__gitcomp_nl_append "$@"
}
and then complete branch.* using two calls to __gitcomp_*, letting
the first one clear and later one(s) accumulate:
__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
__gitcomp_nl_append $"autosetupmerge\nautosetuprebase\n" "$pfx" "$cur_" " "
Will queue as-is.
Thanks.
next prev parent reply other threads:[~2014-01-02 23:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-30 14:52 [PATCH 0/4] Fix branch.autosetup(merge|rebase) completion Ramkumar Ramachandra
2013-12-30 14:52 ` [PATCH 1/4] completion: prioritize ./git-completion.bash Ramkumar Ramachandra
2013-12-30 14:52 ` [PATCH 2/4] completion: introduce __gitcomp_2 () Ramkumar Ramachandra
2014-01-02 23:47 ` Junio C Hamano [this message]
2014-01-03 7:51 ` Ramkumar Ramachandra
2014-01-03 17:49 ` Junio C Hamano
2014-01-03 19:09 ` Ramkumar Ramachandra
2013-12-30 14:52 ` [PATCH 3/4] completion: fix branch.autosetup(merge|rebase) Ramkumar Ramachandra
2014-01-02 23:56 ` Junio C Hamano
2014-01-03 7:36 ` Ramkumar Ramachandra
2014-01-03 17:32 ` Junio C Hamano
2014-01-03 18:58 ` Ramkumar Ramachandra
2014-01-03 19:13 ` Junio C Hamano
2013-12-30 14:52 ` [PATCH 4/4] completion: fix remote.pushdefault Ramkumar Ramachandra
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=xmqqeh4qndxs.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=artagnon@gmail$(echo .)com \
--cc=felipe.contreras@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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