Skip to content

Commit 8b1d913

Browse files
szedergitster
authored andcommitted
revision.c: use skip_prefix() in handle_revision_pseudo_opt()
Instead of starts_with() and a bunch of magic numbers. Signed-off-by: SZEDER Gábor <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 479b3d9 commit 8b1d913

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

revision.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,20 +2099,20 @@ static int handle_revision_pseudo_opt(const char *submodule,
20992099
} else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {
21002100
add_ref_exclusion(&revs->ref_excludes, optarg);
21012101
return argcount;
2102-
} else if (starts_with(arg, "--branches=")) {
2102+
} else if (skip_prefix(arg, "--branches=", &optarg)) {
21032103
struct all_refs_cb cb;
21042104
init_all_refs_cb(&cb, revs, *flags);
2105-
for_each_glob_ref_in(handle_one_ref, arg + 11, "refs/heads/", &cb);
2105+
for_each_glob_ref_in(handle_one_ref, optarg, "refs/heads/", &cb);
21062106
clear_ref_exclusion(&revs->ref_excludes);
2107-
} else if (starts_with(arg, "--tags=")) {
2107+
} else if (skip_prefix(arg, "--tags=", &optarg)) {
21082108
struct all_refs_cb cb;
21092109
init_all_refs_cb(&cb, revs, *flags);
2110-
for_each_glob_ref_in(handle_one_ref, arg + 7, "refs/tags/", &cb);
2110+
for_each_glob_ref_in(handle_one_ref, optarg, "refs/tags/", &cb);
21112111
clear_ref_exclusion(&revs->ref_excludes);
2112-
} else if (starts_with(arg, "--remotes=")) {
2112+
} else if (skip_prefix(arg, "--remotes=", &optarg)) {
21132113
struct all_refs_cb cb;
21142114
init_all_refs_cb(&cb, revs, *flags);
2115-
for_each_glob_ref_in(handle_one_ref, arg + 10, "refs/remotes/", &cb);
2115+
for_each_glob_ref_in(handle_one_ref, optarg, "refs/remotes/", &cb);
21162116
clear_ref_exclusion(&revs->ref_excludes);
21172117
} else if (!strcmp(arg, "--reflog")) {
21182118
add_reflogs_to_pending(revs, *flags);
@@ -2122,14 +2122,14 @@ static int handle_revision_pseudo_opt(const char *submodule,
21222122
*flags ^= UNINTERESTING | BOTTOM;
21232123
} else if (!strcmp(arg, "--no-walk")) {
21242124
revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
2125-
} else if (starts_with(arg, "--no-walk=")) {
2125+
} else if (skip_prefix(arg, "--no-walk=", &optarg)) {
21262126
/*
21272127
* Detached form ("--no-walk X" as opposed to "--no-walk=X")
21282128
* not allowed, since the argument is optional.
21292129
*/
2130-
if (!strcmp(arg + 10, "sorted"))
2130+
if (!strcmp(optarg, "sorted"))
21312131
revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
2132-
else if (!strcmp(arg + 10, "unsorted"))
2132+
else if (!strcmp(optarg, "unsorted"))
21332133
revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED;
21342134
else
21352135
return error("invalid argument to --no-walk");

0 commit comments

Comments
 (0)