Re: [PATCH v3] Completion must sort before using uniq
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 25, 2012, 06:32 UTC
- Message-ID
- <7vtxsexkdn.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CAFj1UpH8h6c7xHuRG6F+pLy5YMvsJ0QdXsotCpLKnht0PsdiNw@mail.gmail.com>
Marc Khouzam <marc.khouzam@gmail.com> writes:
Show 19 quoted lines
> The user can be presented with invalid completion results > when trying to complete a 'git checkout' command. This can happen > when using a branch name prefix that matches multiple remote branches. > > For example, if available branches are: > master > remotes/GitHub/maint > remotes/GitHub/master > remotes/origin/maint > remotes/origin/master > > When performing completion on 'git checkout ma' the user will be > given the choices: > maint > master > ... > When dealing with 'git checkout mai', the list will be: > maint > maint
Wow, the description feels a tad repetitive for a one liner (it describes "uniq -u" without pre-sort is wrong at least three times), it would be better than no log message ;-)
I originally thought "uniq -u" was a misspelled "sort -u" when I first saw your shorter version, but reading the code to see what is fed to the command made it immediately obvious "sort | uniq -u" is the right fix. With the above explanation, you do not even need to read the code to see what is fed to the command (it is explained ;-).
So, thanks for the fix.