Completion must sort before using uniq
Re-adding git@vger...
Quoted 30 lines
From: Marc Khouzam [mailto:[email protected]]
Sent: Friday, November 23, 2012 11:51 AM
To: Joachim Schmitz
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] Completion must sort before using uniqQuoted 4 lines · Joachim Schmitz
Quoted 2 lines · Marc Khouzam
The uniq program only works with sorted input. The man page states "uniq prints the unique lines in a sorted file".
...
Quoted 12 lines
contrib/completion/git-completion.bash __git_refs () · line 324
Quoted 8 lines
contrib/completion/git-completion.bash +1
-1@@ -321,7 +321,7 @@ __git_refs () if [[ "$ref" == "$cur"* ]]; then echo "$ref" fi - done | uniq -u + done | sort | uniq -uIs '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."
Quoted 4 lines
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?!?
Quoted 1 line
Is 'sort | uniq -u' not POSIX?
It is. It is one process more though.
Bye, Jojo
Quoted 5 lines
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?!?
From the german translation of uniq's man-page, you can deduct that "only
print unique lines" actually means: "print lines that are _not repeated_ in the input".
A short test confirms that. i.e.:
printf "a\nb\nb\nc\n" | uniq -u
gives:
a
c
Sascha
Quoted 14 lines
From: Sascha Cunz [mailto:[email protected]]
Sent: Friday, November 23, 2012 1:26 PM
To: Joachim Schmitz
Cc: 'Marc Khouzam'; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Completion must sort before using uniqQuoted 3 lines
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?!?
From the german translation of uniq's man-page, you can deduct that "only print unique lines" actually means: "print lines that are
_notrepeated_in the input".
Quoted 7 lines
A short test confirms that. i.e.:
printf "a\nb\nb\nc\n" | uniq -ugives:
a
c
Ah, OK, then I rest my case. Sorry for the noise.