From: Junio C Hamano <gitster@pobox.com>
To: "Gábor Szeder" <szeder@ira.uka.de>
Cc: git@vger.kernel.org, Ramkumar Ramachandra <artagnon@gmail.com>,
Felipe Contreras <felipe.contreras@gmail.com>
Subject: Re: [PATCH 5/5] completion: fix completion of certain aliases
Date: Mon, 14 Apr 2014 13:20:29 -0700 [thread overview]
Message-ID: <xmqqmwfnoe7m.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <E1WZEWT-0002R7-1d@iramx2.ira.uni-karlsruhe.de> ("Gábor Szeder"'s message of "Sun, 13 Apr 2014 11:38:23 +0430")
Gábor Szeder <szeder@ira.uka.de> writes:
> words[] is just fine, we never modify it after it is filled by
> _get_comp_words_by_ref() at the very beginning.
Hmph. I would have understood if the latter were "we never look at
it (to decide what to do)". "we never modify it" does not sound
like an enough justification behind "words[] is just fine"---maybe I
am not reading you correctly.
> The root of the problem is that the expected position of the name
> of the git command in __git_complete_remote_or_refspec() is
> hardcoded as words[1], but that is not the case when:
>
> 1) it's an alias, as in Felipe's example: git p ori<TAB>,
> because while the index is ok, the content is not.
>
> 2) in presence of options of the main git command: git -c
> foo=bar push ori<TAB>, because the index is off.
>
> 3) the command is a shell alias for which the user explicitly
> set the completion function with __git_complete() (at his own
> risk): alias gp="git push"; __git_complete gp _git_push; gp
> ori<TAB> Neither the index nor the content are ok.
>
> Fixing the hard-coded indexing would only solve 2) but not 1) and
> 3), as it obviously couldn't turn the git or shell alias into a
> git command on its own.
>
> Felipe's patch only deals with 1), as it only kicks in in case of
> a git alias.
Yeah, do completions for commands (not just for the ones that use
remote-or-refspec Felipe's patch addresses) have trouble with the
latter two in general? If that is the case,...
> Communicating the name of the git command to
> __git_complete_remote_or_refspec() by its callers via a new
> variable as suggested by Junio, or perhaps by an additional
> parameter to the function is IMHO the right thing to do, because,
> unless I'm missing something, it would make all three cases work.
... while the above analysis may be correct, taking Felipe's patch
to address only (1) and leaving a solution to the more general
words[1] problem for other patches on top might not be too bad an
approach.
Unless
(A) remote-or-refspec thing is the primary offender, and other
commands do not suffer from the words[1] problem, in which case
I tend to agree that an additional parameter would be the way
to go (there are only a few callers of the function); or
(B) even if words[1] problem is more widespread, such a more
general solution to all three issues can be coded cleanly and
quickly, without having to have Felipe's patch as a stop-gap
measure.
that is.
I'll keep Felipe's patch in the meantime to 'pu'.
Thanks.
next prev parent reply other threads:[~2014-04-14 20:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-13 7:08 [PATCH 5/5] completion: fix completion of certain aliases Gábor Szeder
2014-04-14 20:20 ` Junio C Hamano [this message]
2014-04-19 1:26 ` Felipe Contreras
-- strict thread matches above, loose matches on Subject: below --
2014-04-09 18:49 [PATCH 0/5] Fixes Felipe Contreras
2014-04-09 18:50 ` [PATCH 5/5] completion: fix completion of certain aliases Felipe Contreras
2014-04-09 19:33 ` Junio C Hamano
2014-04-09 20:36 ` Felipe Contreras
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=xmqqmwfnoe7m.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=artagnon@gmail.com \
--cc=felipe.contreras@gmail.com \
--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.
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.