git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Joachim Schmitz" <jojo@schmitz-digital.de>
To: "'Marc Khouzam'" <marc.khouzam@gmail.com>, <git@vger.kernel.org>
Cc: <szeder@ira.uka.de>, <felipe.contreras@gmail.com>
Subject: RE: [PATCH] Completion must sort before using uniq
Date: Fri, 23 Nov 2012 13:15:59 +0100	[thread overview]
Message-ID: <003b01cdc974$4cdd1900$e6974b00$@schmitz-digital.de> (raw)
In-Reply-To: <CAFj1UpEMKq9zH3nbLwYrNZRmd52_KEcN5BBrzGg2jxCzd+fsbA@mail.gmail.com>

Re-adding git@vger...

> From: Marc Khouzam [mailto:marc.khouzam@gmail.com]
> Sent: Friday, November 23, 2012 11:51 AM
> To: Joachim Schmitz
> Cc: szeder@ira.uka.de; felipe.contreras@gmail.com
> Subject: Re: [PATCH] Completion must sort before using uniq
> 
> On Fri, Nov 23, 2012 at 3:10 AM, Joachim Schmitz
> <jojo@schmitz-digital.de> wrote:
> > Marc Khouzam wrote:
> >> The uniq program only works with sorted input.  The man page states
> >> "uniq prints the unique lines in a sorted file".
> > ...
> >> --- a/contrib/completion/git-completion.bash
> >> +++ b/contrib/completion/git-completion.bash
> >> @@ -321,7 +321,7 @@ __git_refs ()
> >>                                if [[ "$ref" == "$cur"* ]]; then
> >>                                        echo "$ref"
> >>                                fi
> >> -                       done | uniq -u
> >> +                       done | sort | uniq -u
> >
> > Is 'sort -u' not universally available and sufficient here? It is POSIX
> > at least:
> > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html
> 
> "-u Unique: suppress all but one in each set of lines having equal
> keys. If used with the -c option, check that there are no lines with
> duplicate keys, in addition to checking that the input file is
> sorted."
> 
> What the code aims to do is to only show lines that are not
> duplicated.  'sort -u' would still output one line for each duplicated
> one.  It seems 'sort -u' is the equivalent of 'sort | uniq' but won't
> replace 'sort | uniq -u'.

I can't see the difference and in fact don't understand uniq's -u option al all
Linux man pages say: "only print unique lines", but that is what uniq does by default anyway?!?

> Is 'sort | uniq -u' not POSIX?

It is. It is one process more though.

Bye, Jojo

       reply	other threads:[~2012-11-23 12:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <002201cdc952$00159c90$0040d5b0$@schmitz-digital.de>
     [not found] ` <CAFj1UpEMKq9zH3nbLwYrNZRmd52_KEcN5BBrzGg2jxCzd+fsbA@mail.gmail.com>
2012-11-23 12:15   ` Joachim Schmitz [this message]
2012-11-23 12:26     ` [PATCH] Completion must sort before using uniq Sascha Cunz
2012-11-23 12:36       ` Joachim Schmitz
     [not found] <1353557598-4820-1-git-send-email-marc.khouzam@gmail.com>
2012-11-22  4:16 ` Marc Khouzam
2012-11-23  8:09   ` Joachim Schmitz
2012-11-23  8:21   ` 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='003b01cdc974$4cdd1900$e6974b00$@schmitz-digital.de' \
    --to=jojo@schmitz-digital.de \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=marc.khouzam@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).