git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Felipe Contreras
Message 8 of 8 in “Completion must sort before using uniq”
  1. Completion must sort before using uniqMarc Khouzam, Nov 22, 2012
  2. Joachim SchmitzNov 23, 2012
  3. Felipe ContrerasNov 23, 2012
  4. Completion must sort before using uniqMarc Khouzam, Nov 23, 2012
  5. Felipe ContrerasNov 23, 2012
  6. Completion must sort before using uniqMarc Khouzam, Nov 23, 2012
  7. Felipe ContrerasNov 23, 2012
  8. Junio C HamanoNov 25, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.