summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-07-10 04:07:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-10 17:56:50 (GMT)
commitce856044681331d19b867426726db7edd12f1713 (patch)
tree27872d7598e05e232737976e3787529e3c384f33 /builtin
parent67a31f612830e79fe768ac886ed9ef7eadd8fb10 (diff)
downloadgit-ce856044681331d19b867426726db7edd12f1713.zip
git-ce856044681331d19b867426726db7edd12f1713.tar.gz
git-ce856044681331d19b867426726db7edd12f1713.tar.bz2
tag: use skip_prefix instead of magic numbers
We can make the parsing of the --sort parameter a bit more readable by having skip_prefix keep our pointer up to date. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/tag.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index c6e8a71..1101c19 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -524,18 +524,14 @@ static int parse_opt_sort(const struct option *opt, const char *arg, int unset)
int *sort = opt->value;
int flags = 0;
- if (*arg == '-') {
+ if (skip_prefix(arg, "-", &arg))
flags |= REVERSE_SORT;
- arg++;
- }
- if (starts_with(arg, "version:")) {
- *sort = VERCMP_SORT;
- arg += 8;
- } else if (starts_with(arg, "v:")) {
+
+ if (skip_prefix(arg, "version:", &arg) || skip_prefix(arg, "v:", &arg))
*sort = VERCMP_SORT;
- arg += 2;
- } else
+ else
*sort = STRCMP_SORT;
+
if (strcmp(arg, "refname"))
die(_("unsupported sort specification %s"), arg);
*sort |= flags;