On Thu, Nov 22, 2012 at 5:16 AM, Marc Khouzam <marc.khouzam@xxxxxxxxx> wrote: > The uniq program only works with sorted input. The man page states > "uniq prints the unique lines in a sorted file". > > When __git_refs use the guess heuristic employed by checkout for > tracking branches it wants to consider remote branches but only if > the branch name is unique. To do that, it calls 'uniq -u'. However > the input given to 'uniq -u' is not sorted. > > For example if all available branches are: > master > remotes/GitHub/maint > remotes/GitHub/master > remotes/origin/maint > remotes/origin/master > > When performing completion on 'git checkout ma' the choices given are > maint > master > but when performing completion on 'git checkout mai', no choices > appear, which is obviously contradictory. > > The reason is that, when dealing with 'git checkout ma', > "__git_refs '' 1" will find the following list: > master > maint > master > maint > master > which, when passed to 'uniq -u' will remain the same. > But when dealing with 'git checkout mai', the list will be: > maint > maint > which happens to be sorted and will be emptied by 'uniq -u'. > > The solution is to first call 'sort' and then 'uniq -u'. The solution to what? This seems to be the right thing indeed, but you don't explain what is the actual problem that is being solved. What does the user experience? What would (s)he experience after the patch? -- Felipe Contreras -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html