summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-02-12 20:41:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-12 20:41:37 (GMT)
commit44cba9c4b37159ef2f09c122c358c74bde466677 (patch)
tree5159fcb2a5ff726a0d13d89b5db4ac07484d5c1c /builtin
parent556ccd4dd2943009270b46b9af443a396bff4dfc (diff)
parent145136a95a8755528aa012a4ce0ed50d1ec39e24 (diff)
downloadgit-44cba9c4b37159ef2f09c122c358c74bde466677.zip
git-44cba9c4b37159ef2f09c122c358c74bde466677.tar.gz
git-44cba9c4b37159ef2f09c122c358c74bde466677.tar.bz2
Merge branch 'jc/skip-prefix'
Code simplification. * jc/skip-prefix: C: use skip_prefix() to avoid hardcoded string length
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fast-export.c3
-rw-r--r--builtin/reflog.c9
2 files changed, 6 insertions, 6 deletions
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index dbec4df..164406f 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -870,8 +870,7 @@ static void handle_tag(const char *name, struct tag *tag)
printf("reset %s\nfrom %s\n\n",
name, oid_to_hex(&null_oid));
}
- if (starts_with(name, "refs/tags/"))
- name += 10;
+ skip_prefix(name, "refs/tags/", &name);
printf("tag %s\n", name);
if (mark_tags) {
mark_next_object(&tag->object);
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 4d34309..81dfd56 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -560,15 +560,16 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
+
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
flags |= EXPIRE_REFLOGS_DRY_RUN;
- else if (starts_with(arg, "--expire=")) {
- if (parse_expiry_date(arg + 9, &cb.cmd.expire_total))
+ else if (skip_prefix(arg, "--expire=", &arg)) {
+ if (parse_expiry_date(arg, &cb.cmd.expire_total))
die(_("'%s' is not a valid timestamp"), arg);
explicit_expiry |= EXPIRE_TOTAL;
}
- else if (starts_with(arg, "--expire-unreachable=")) {
- if (parse_expiry_date(arg + 21, &cb.cmd.expire_unreachable))
+ else if (skip_prefix(arg, "--expire-unreachable=", &arg)) {
+ if (parse_expiry_date(arg, &cb.cmd.expire_unreachable))
die(_("'%s' is not a valid timestamp"), arg);
explicit_expiry |= EXPIRE_UNREACH;
}