Skip to content

Commit f357797

Browse files
committed
Merge branch 'jk/skip-prefix'
One more to an already graduated topic. * jk/skip-prefix: tag: use skip_prefix instead of magic numbers
2 parents 7591e2c + ce85604 commit f357797

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

builtin/tag.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -524,18 +524,14 @@ static int parse_opt_sort(const struct option *opt, const char *arg, int unset)
524524
int *sort = opt->value;
525525
int flags = 0;
526526

527-
if (*arg == '-') {
527+
if (skip_prefix(arg, "-", &arg))
528528
flags |= REVERSE_SORT;
529-
arg++;
530-
}
531-
if (starts_with(arg, "version:")) {
532-
*sort = VERCMP_SORT;
533-
arg += 8;
534-
} else if (starts_with(arg, "v:")) {
529+
530+
if (skip_prefix(arg, "version:", &arg) || skip_prefix(arg, "v:", &arg))
535531
*sort = VERCMP_SORT;
536-
arg += 2;
537-
} else
532+
else
538533
*sort = STRCMP_SORT;
534+
539535
if (strcmp(arg, "refname"))
540536
die(_("unsupported sort specification %s"), arg);
541537
*sort |= flags;

0 commit comments

Comments
 (0)