Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
rev-parse: use skip_prefix when parsing options
author
Jeff King
<peff@peff.net>
Wed, 15 Mar 2017 20:05:36 +0000
(16:05 -0400)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 15 Mar 2017 21:00:28 +0000
(14:00 -0700)
Using skip_prefix lets us avoid manually-counted offsets
into the argument string. This patch converts the simple and
obvious cases.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rev-parse.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
e7e07d5
)
diff --git
a/builtin/rev-parse.c
b/builtin/rev-parse.c
index ff13e59e1dbd200b6e7cf7d1c508b620b19e8cc7..48338ac760b1a7c3aa4fad848ad5a669734cb800 100644
(file)
--- a/
builtin/rev-parse.c
+++ b/
builtin/rev-parse.c
@@
-719,8
+719,8
@@
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_ref(show_reference, NULL);
continue;
}
for_each_ref(show_reference, NULL);
continue;
}
- if (s
tarts_with(arg, "--disambiguate="
)) {
- for_each_abbrev(arg
+ 15
, show_abbrev, NULL);
+ if (s
kip_prefix(arg, "--disambiguate=", &arg
)) {
+ for_each_abbrev(arg, show_abbrev, NULL);
continue;
}
if (!strcmp(arg, "--bisect")) {
continue;
}
if (!strcmp(arg, "--bisect")) {
@@
-728,8
+728,8
@@
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_ref_in("refs/bisect/good", anti_reference, NULL);
continue;
}
for_each_ref_in("refs/bisect/good", anti_reference, NULL);
continue;
}
- if (s
tarts_with(arg, "--branches="
)) {
- for_each_glob_ref_in(show_reference, arg
+ 11
,
+ if (s
kip_prefix(arg, "--branches=", &arg
)) {
+ for_each_glob_ref_in(show_reference, arg,
"refs/heads/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
"refs/heads/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
@@
-739,8
+739,8
@@
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
clear_ref_exclusion(&ref_excludes);
continue;
}
clear_ref_exclusion(&ref_excludes);
continue;
}
- if (s
tarts_with(arg, "--tags="
)) {
- for_each_glob_ref_in(show_reference, arg
+ 7
,
+ if (s
kip_prefix(arg, "--tags=", &arg
)) {
+ for_each_glob_ref_in(show_reference, arg,
"refs/tags/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
"refs/tags/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
@@
-750,13
+750,13
@@
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
clear_ref_exclusion(&ref_excludes);
continue;
}
clear_ref_exclusion(&ref_excludes);
continue;
}
- if (s
tarts_with(arg, "--glob="
)) {
- for_each_glob_ref(show_reference, arg
+ 7
, NULL);
+ if (s
kip_prefix(arg, "--glob=", &arg
)) {
+ for_each_glob_ref(show_reference, arg, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
clear_ref_exclusion(&ref_excludes);
continue;
}
- if (s
tarts_with(arg, "--remotes="
)) {
- for_each_glob_ref_in(show_reference, arg
+ 10
,
+ if (s
kip_prefix(arg, "--remotes=", &arg
)) {
+ for_each_glob_ref_in(show_reference, arg,
"refs/remotes/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
"refs/remotes/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
@@
-766,8
+766,8
@@
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
clear_ref_exclusion(&ref_excludes);
continue;
}
clear_ref_exclusion(&ref_excludes);
continue;
}
- if (s
tarts_with(arg, "--exclude="
)) {
- add_ref_exclusion(&ref_excludes, arg
+ 10
);
+ if (s
kip_prefix(arg, "--exclude=", &arg
)) {
+ add_ref_exclusion(&ref_excludes, arg);
continue;
}
if (!strcmp(arg, "--show-toplevel")) {
continue;
}
if (!strcmp(arg, "--show-toplevel")) {
@@
-849,20
+849,20
@@
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
}
continue;
}
}
continue;
}
- if (s
tarts_with(arg, "--since="
)) {
- show_datestring("--max-age=", arg
+8
);
+ if (s
kip_prefix(arg, "--since=", &arg
)) {
+ show_datestring("--max-age=", arg);
continue;
}
continue;
}
- if (s
tarts_with(arg, "--after="
)) {
- show_datestring("--max-age=", arg
+8
);
+ if (s
kip_prefix(arg, "--after=", &arg
)) {
+ show_datestring("--max-age=", arg);
continue;
}
continue;
}
- if (s
tarts_with(arg, "--before="
)) {
- show_datestring("--min-age=", arg
+9
);
+ if (s
kip_prefix(arg, "--before=", &arg
)) {
+ show_datestring("--min-age=", arg);
continue;
}
continue;
}
- if (s
tarts_with(arg, "--until="
)) {
- show_datestring("--min-age=", arg
+8
);
+ if (s
kip_prefix(arg, "--until=", &arg
)) {
+ show_datestring("--min-age=", arg);
continue;
}
if (show_flag(arg) && verify)
continue;
}
if (show_flag(arg) && verify)