{"thread":{"id":"32177","subject":"RE: [PATCH] Completion must sort before using uniq","startedAt":"2012-11-23T12:15:59Z","lastAt":"2012-11-23T12:36:03Z","messageCount":3,"participants":["Joachim Schmitz","Sascha Cunz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"203697","messageId":"003b01cdc974$4cdd1900$e6974b00$@schmitz-digital.de","threadId":"32177","inReplyTo":"CAFj1UpEMKq9zH3nbLwYrNZRmd52_KEcN5BBrzGg2jxCzd+fsbA@mail.gmail.com","subject":"RE: [PATCH] Completion must sort before using uniq","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-11-23T12:15:59Z","receivedAt":"2012-11-23T12:15:59Z","isPatch":true,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"Re-adding git@vger...\n\n> From: Marc Khouzam [mailto:marc.khouzam@gmail.com]\n> Sent: Friday, November 23, 2012 11:51 AM\n> To: Joachim Schmitz\n> Cc: szeder@ira.uka.de; felipe.contreras@gmail.com\n> Subject: Re: [PATCH] Completion must sort before using uniq\n> \n> On Fri, Nov 23, 2012 at 3:10 AM, Joachim Schmitz\n> <jojo@schmitz-digital.de> wrote:\n> > Marc Khouzam wrote:\n> >> The uniq program only works with sorted input.  The man page states\n> >> \"uniq prints the unique lines in a sorted file\".\n> > ...\n> >> --- a/contrib/completion/git-completion.bash\n> >> +++ b/contrib/completion/git-completion.bash\n> >> @@ -321,7 +321,7 @@ __git_refs ()\n> >>                                if [[ \"$ref\" == \"$cur\"* ]]; then\n> >>                                        echo \"$ref\"\n> >>                                fi\n> >> -                       done | uniq -u\n> >> +                       done | sort | uniq -u\n> >\n> > Is 'sort -u' not universally available and sufficient here? It is POSIX\n> > at least:\n> > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html\n> \n> \"-u Unique: suppress all but one in each set of lines having equal\n> keys. If used with the -c option, check that there are no lines with\n> duplicate keys, in addition to checking that the input file is\n> sorted.\"\n> \n> What the code aims to do is to only show lines that are not\n> duplicated.  'sort -u' would still output one line for each duplicated\n> one.  It seems 'sort -u' is the equivalent of 'sort | uniq' but won't\n> replace 'sort | uniq -u'.\n\nI can't see the difference and in fact don't understand uniq's -u option al all\nLinux man pages say: \"only print unique lines\", but that is what uniq does by default anyway?!?\n\n> Is 'sort | uniq -u' not POSIX?\n\nIt is. It is one process more though.\n\nBye, Jojo\n"},{"id":"203698","messageId":"2630847.8aaR79v5Od@blacky","threadId":"32177","inReplyTo":"003b01cdc974$4cdd1900$e6974b00$@schmitz-digital.de","subject":"Re: [PATCH] Completion must sort before using uniq","fromName":"Sascha Cunz","fromEmail":"sascha-ml@babbelbox.org","sentAt":"2012-11-23T12:26:28Z","receivedAt":"2012-11-23T12:26:28Z","isPatch":true,"sender":{"key":"sascha-ml@babbelbox.org","avatar":null},"body":"> I can't see the difference and in fact don't understand uniq's -u option al\n> all Linux man pages say: \"only print unique lines\", but that is what uniq\n> does by default anyway?!?\n\n>From the german translation of uniq's man-page, you can deduct that \"only \nprint unique lines\" actually means: \"print lines that are _not repeated_ in \nthe input\".\n\nA short test confirms that. i.e.:\n\n\tprintf \"a\\nb\\nb\\nc\\n\" | uniq -u\n\ngives:\n\ta\n\tc\n\nSascha\n"},{"id":"203699","messageId":"003c01cdc977$1a8a60e0$4f9f22a0$@schmitz-digital.de","threadId":"32177","inReplyTo":"2630847.8aaR79v5Od@blacky","subject":"RE: [PATCH] Completion must sort before using uniq","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-11-23T12:36:03Z","receivedAt":"2012-11-23T12:36:03Z","isPatch":true,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Sascha Cunz [mailto:sascha-ml@babbelbox.org]\n> Sent: Friday, November 23, 2012 1:26 PM\n> To: Joachim Schmitz\n> Cc: 'Marc Khouzam'; git@vger.kernel.org; szeder@ira.uka.de; felipe.contreras@gmail.com\n> Subject: Re: [PATCH] Completion must sort before using uniq\n> \n> > I can't see the difference and in fact don't understand uniq's -u option al\n> > all Linux man pages say: \"only print unique lines\", but that is what uniq\n> > does by default anyway?!?\n> \n> From the german translation of uniq's man-page, you can deduct that \"only\n> print unique lines\" actually means: \"print lines that are _not repeated_ in\n> the input\".\n> \n> A short test confirms that. i.e.:\n> \n> \tprintf \"a\\nb\\nb\\nc\\n\" | uniq -u\n> \n> gives:\n> \ta\n> \tc\n\nAh, OK, then I rest my case. Sorry for the noise.\n"}]}