Merge branch 'jk/skip-prefix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 16 Jul 2014 18:33:06 +0000 (11:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Jul 2014 18:33:06 +0000 (11:33 -0700)
One more to an already graduated topic.

* jk/skip-prefix:
tag: use skip_prefix instead of magic numbers

1  2 
builtin/tag.c
diff --combined builtin/tag.c
index ef765563388c384a127d27eaf7ee6fd1badfe84f,1101c19596c549e50b2e2b6c640a5e318cefb802..9d7643f127e7c0ea965ebf599574749c950d769f
@@@ -83,7 -83,7 +83,7 @@@ static int in_commit_list(const struct 
  enum contains_result {
        CONTAINS_UNKNOWN = -1,
        CONTAINS_NO = 0,
 -      CONTAINS_YES = 1,
 +      CONTAINS_YES = 1
  };
  
  /*
@@@ -524,18 -524,14 +524,14 @@@ static int parse_opt_sort(const struct 
        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;