Re: [PATCHv2 11/14] completion: let 'for-each-ref' sort remote branches for 'checkout' DWIMery
- From
Jeff King <peff@peff.net>
- Date
- Mar 24, 2017, 19:53 UTC
- Message-ID
- <20170324195357.cv3pjt3stjg6cqjm@sigill.intra.peff.net>
- In-Reply-To
- <20170323152924.23944-12-szeder.dev@gmail.com>
On Thu, Mar 23, 2017 at 04:29:21PM +0100, SZEDER Gábor wrote:
Show 12 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash > index 394dcece6..d26312899 100644 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -423,8 +423,9 @@ __git_refs () > # Try to find a remote branch that matches the completion word > # but only output if the branch name is unique > __git for-each-ref --format="%(refname:strip=3)" \ > + --sort="refname:strip=3" \ > "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \ > - sort | uniq -u > + uniq -u
I wonder if it would be worth adding a "--unique" option to for-each-ref. I guess the definition of "unique" may change though (here you'd want to do it on the sort key, but other cases may want unique branch names sorted by time, which is less trivial).
-Peff