On Wed, Feb 19, 2014 at 9:09 PM, Jeff King <peff@xxxxxxxx> wrote: > On Wed, Feb 19, 2014 at 08:39:27PM +0700, Nguyễn Thái Ngọc Duy wrote: > >> --sort=version sorts tags as versions. GNU extension's strverscmp is >> used and no real compat implementation is provided so this is Linux only. > > Sounds like a good goal. > > I wonder, if we were to merge the for-each-ref and tag > implementations[1], how this would integrate with for-each-ref's > sorting. It can sort on arbitrary fields like "--sort=-*authordate". I > think given the syntax you provide, this would fall out naturally as > just another key (albeit a slightly magical one, as it is building on > the %(refname:short) field but using a different comparator). > > Would we ever want to version-sort any other field? Perhaps > %(content:subject) for a tag? I'm not sure what would be the most > natural way to specify that. Maybe "--sort=version:content:subject", > with just "--version" as a synonym for "version:refname:short". If f-e-r and tag share code and syntax then we could use another letter for this sort type (like we use '-' to reverse sort order). I think that would make the implementation easier as well. So we could have --sort=.refname for version sorting refname, --sort=-.refname for reversed version sort, and sort=-refname for reverse alphabetical sort. > We don't need to do any of that immediately. This is mostly just me > thinking aloud, to make sure we do not paint ourselves into a corner > compatibility-wise. Good thinking. If you plan to use the exact same sort syntax f-e-r uses now, pick a letter (the dot I used above is probably not the best), I'll rewrite this patch to use the same syntax. > > -Peff > > [1] I have patches which I really need to polish and send out that > combine the ref-selection code (so tag, branch, and for-each-ref all > know "--merged", "--contains", etc). I'd really like to combine the > sorting and formatting code, too, so everybody can use "--sort" and > "--format" with all of the associated fields. -- Duy -- 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