On Tue, Feb 25, 2014 at 07:22:15PM +0700, Nguyễn Thái Ngọc Duy wrote: > versioncmp() is copied from string/strverscmp.c in glibc commit > ee9247c38a8def24a59eb5cfb7196a98bef8cfdc, reformatted to Git coding > style. The implementation is under LGPL-2.1 and according to [1] I can > relicense it to GPLv2. Cool. I think doing this makes the most sense, as we do not have to worry about build-time config (and I do not see any particular reason why we would want to use the system strverscmp on glibc systems). > +static int parse_opt_sort(const struct option *opt, const char *arg, int unset) > +{ > + int *sort = opt->value; > + if (*arg == '-') { > + *sort = REVERSE_SORT; > + arg++; > + } else > + *sort = STRCMP_SORT; > + if (starts_with(arg, "version:")) { > + *sort |= VERCMP_SORT; > + arg += 8; > + } else if (starts_with(arg, "v:")) { > + *sort |= VERCMP_SORT; > + arg += 2; > + } > + if (strcmp(arg, "refname")) > + die(_("unsupported sort specification %s"), arg); I found this logic a bit weird, as STRCMP_SORT and VERCMP_SORT are not mutually exclusive flags, but REVERSE and STRCMP are. I would have thought REVERSE is the flag, and the other two are selections. Like: int flags = 0; if (*arg == '-') { flags |= REVERSE_SORT; arg++; } if (starts_with(arg, "version:")) { *sort = VERCMP_SORT; arg += 8; } else *sort = STRCMP_SORT; *sort |= flags; I think they end up doing the same thing, but maybe I am missing something. -Peff -- 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