summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alias.c2
-rw-r--r--attr.c2
-rw-r--r--bisect.c4
-rw-r--r--branch.c4
-rw-r--r--builtin/apply.c12
-rw-r--r--builtin/archive.c4
-rw-r--r--builtin/branch.c6
-rw-r--r--builtin/checkout.c8
-rw-r--r--builtin/clean.c4
-rw-r--r--builtin/clone.c8
-rw-r--r--builtin/column.c2
-rw-r--r--builtin/commit.c10
-rw-r--r--builtin/describe.c2
-rw-r--r--builtin/fast-export.c2
-rw-r--r--builtin/fetch-pack.c6
-rw-r--r--builtin/fetch.c18
-rw-r--r--builtin/fmt-merge-msg.c10
-rw-r--r--builtin/for-each-ref.c20
-rw-r--r--builtin/fsck.c6
-rw-r--r--builtin/help.c8
-rw-r--r--builtin/index-pack.c8
-rw-r--r--builtin/init-db.c2
-rw-r--r--builtin/log.c8
-rw-r--r--builtin/ls-remote.c4
-rw-r--r--builtin/mailinfo.c16
-rw-r--r--builtin/merge-recursive.c4
-rw-r--r--builtin/merge.c12
-rw-r--r--builtin/name-rev.c6
-rw-r--r--builtin/notes.c2
-rw-r--r--builtin/pack-objects.c2
-rw-r--r--builtin/prune.c4
-rw-r--r--builtin/receive-pack.c6
-rw-r--r--builtin/reflog.c4
-rw-r--r--builtin/remote.c22
-rw-r--r--builtin/repack.c2
-rw-r--r--builtin/rev-parse.c26
-rw-r--r--builtin/send-pack.c8
-rw-r--r--builtin/shortlog.c6
-rw-r--r--builtin/show-branch.c20
-rw-r--r--builtin/show-ref.c6
-rw-r--r--builtin/symbolic-ref.c2
-rw-r--r--builtin/tag.c2
-rw-r--r--builtin/unpack-objects.c2
-rw-r--r--builtin/update-ref.c10
-rw-r--r--builtin/upload-archive.c2
-rw-r--r--commit.c6
-rw-r--r--config.c16
-rw-r--r--connect.c2
-rw-r--r--connected.c2
-rw-r--r--convert.c2
-rw-r--r--daemon.c40
-rw-r--r--diff.c56
-rw-r--r--environment.c2
-rw-r--r--fast-import.c80
-rw-r--r--fetch-pack.c12
-rw-r--r--git-compat-util.h2
-rw-r--r--git.c12
-rw-r--r--help.c8
-rw-r--r--http-backend.c4
-rw-r--r--http-push.c4
-rw-r--r--http.c10
-rw-r--r--imap-send.c10
-rw-r--r--log-tree.c8
-rw-r--r--merge-recursive.c6
-rw-r--r--notes-utils.c4
-rw-r--r--notes.c8
-rw-r--r--pager.c2
-rw-r--r--parse-options.c12
-rw-r--r--pathspec.c2
-rw-r--r--pkt-line.c4
-rw-r--r--pretty.c36
-rw-r--r--refs.c30
-rw-r--r--remote-curl.c14
-rw-r--r--remote-testsvn.c10
-rw-r--r--remote.c46
-rw-r--r--revision.c38
-rw-r--r--send-pack.c4
-rw-r--r--sequencer.c8
-rw-r--r--setup.c4
-rw-r--r--sha1_name.c16
-rw-r--r--shell.c2
-rw-r--r--strbuf.c18
-rw-r--r--submodule.c2
-rw-r--r--tag.c10
-rw-r--r--test-line-buffer.c6
-rw-r--r--test-string-list.c2
-rw-r--r--transport-helper.c16
-rw-r--r--transport.c28
-rw-r--r--upload-pack.c10
-rw-r--r--vcs-svn/fast_export.c11
-rw-r--r--wt-status.c16
91 files changed, 484 insertions, 481 deletions
diff --git a/alias.c b/alias.c
index 9938f03c25..5efc3d6986 100644
--- a/alias.c
+++ b/alias.c
@@ -5,7 +5,7 @@ static char *alias_val;
static int alias_lookup_cb(const char *k, const char *v, void *cb)
{
- if (!prefixcmp(k, "alias.") && !strcmp(k + 6, alias_key)) {
+ if (starts_with(k, "alias.") && !strcmp(k + 6, alias_key)) {
if (!v)
return config_error_nonbool(k);
alias_val = xstrdup(v);
diff --git a/attr.c b/attr.c
index 0e774c6f22..8d13d70e80 100644
--- a/attr.c
+++ b/attr.c
@@ -211,7 +211,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
name = cp;
namelen = strcspn(name, blank);
if (strlen(ATTRIBUTE_MACRO_PREFIX) < namelen &&
- !prefixcmp(name, ATTRIBUTE_MACRO_PREFIX)) {
+ starts_with(name, ATTRIBUTE_MACRO_PREFIX)) {
if (!macro_ok) {
fprintf(stderr, "%s not allowed: %s:%d\n",
name, src, lineno);
diff --git a/bisect.c b/bisect.c
index 1e46a4f50e..37200b41f1 100644
--- a/bisect.c
+++ b/bisect.c
@@ -406,9 +406,9 @@ static int register_ref(const char *refname, const unsigned char *sha1,
if (!strcmp(refname, "bad")) {
current_bad_sha1 = xmalloc(20);
hashcpy(current_bad_sha1, sha1);
- } else if (!prefixcmp(refname, "good-")) {
+ } else if (starts_with(refname, "good-")) {
sha1_array_append(&good_revs, sha1);
- } else if (!prefixcmp(refname, "skip-")) {
+ } else if (starts_with(refname, "skip-")) {
sha1_array_append(&skipped_revs, sha1);
}
diff --git a/branch.c b/branch.c
index 9e6c68edaf..723a36bc54 100644
--- a/branch.c
+++ b/branch.c
@@ -50,7 +50,7 @@ static int should_setup_rebase(const char *origin)
void install_branch_config(int flag, const char *local, const char *origin, const char *remote)
{
const char *shortname = remote + 11;
- int remote_is_branch = !prefixcmp(remote, "refs/heads/");
+ int remote_is_branch = starts_with(remote, "refs/heads/");
struct strbuf key = STRBUF_INIT;
int rebasing = should_setup_rebase(origin);
@@ -272,7 +272,7 @@ void create_branch(const char *head,
break;
case 1:
/* Unique completion -- good, only if it is a real branch */
- if (prefixcmp(real_ref, "refs/heads/") &&
+ if (!starts_with(real_ref, "refs/heads/") &&
validate_remote_tracking_branch(real_ref)) {
if (explicit_tracking)
die(_(upstream_not_branch), start_name);
diff --git a/builtin/apply.c b/builtin/apply.c
index ef32e4f624..b0d0986226 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1409,10 +1409,10 @@ static void recount_diff(const char *line, int size, struct fragment *fragment)
case '\\':
continue;
case '@':
- ret = size < 3 || prefixcmp(line, "@@ ");
+ ret = size < 3 || !starts_with(line, "@@ ");
break;
case 'd':
- ret = size < 5 || prefixcmp(line, "diff ");
+ ret = size < 5 || !starts_with(line, "diff ");
break;
default:
ret = -1;
@@ -1798,11 +1798,11 @@ static struct fragment *parse_binary_hunk(char **buf_p,
*status_p = 0;
- if (!prefixcmp(buffer, "delta ")) {
+ if (starts_with(buffer, "delta ")) {
patch_method = BINARY_DELTA_DEFLATED;
origlen = strtoul(buffer + 6, NULL, 10);
}
- else if (!prefixcmp(buffer, "literal ")) {
+ else if (starts_with(buffer, "literal ")) {
patch_method = BINARY_LITERAL_DEFLATED;
origlen = strtoul(buffer + 8, NULL, 10);
}
@@ -3627,12 +3627,12 @@ static int preimage_sha1_in_gitlink_patch(struct patch *p, unsigned char sha1[20
hunk->oldpos == 1 && hunk->oldlines == 1 &&
/* does preimage begin with the heading? */
(preimage = memchr(hunk->patch, '\n', hunk->size)) != NULL &&
- !prefixcmp(++preimage, heading) &&
+ starts_with(++preimage, heading) &&
/* does it record full SHA-1? */
!get_sha1_hex(preimage + sizeof(heading) - 1, sha1) &&
preimage[sizeof(heading) + 40 - 1] == '\n' &&
/* does the abbreviated name on the index line agree with it? */
- !prefixcmp(preimage + sizeof(heading) - 1, p->old_sha1_prefix))
+ starts_with(preimage + sizeof(heading) - 1, p->old_sha1_prefix))
return 0; /* it all looks fine */
/* we may have full object name on the index line */
diff --git a/builtin/archive.c b/builtin/archive.c
index 49178f159e..a1e3b940c2 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -57,9 +57,9 @@ static int run_remote_archiver(int argc, const char **argv,
if (!buf)
die(_("git archive: expected ACK/NAK, got EOF"));
if (strcmp(buf, "ACK")) {
- if (!prefixcmp(buf, "NACK "))
+ if (starts_with(buf, "NACK "))
die(_("git archive: NACK %s"), buf + 5);
- if (!prefixcmp(buf, "ERR "))
+ if (starts_with(buf, "ERR "))
die(_("remote error: %s"), buf + 4);
die(_("git archive: protocol error"));
}
diff --git a/builtin/branch.c b/builtin/branch.c
index 636a16ea4e..b4d771673e 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -81,13 +81,13 @@ static int parse_branch_color_slot(const char *var, int ofs)
static int git_branch_config(const char *var, const char *value, void *cb)
{
- if (!prefixcmp(var, "column."))
+ if (starts_with(var, "column."))
return git_column_config(var, value, "branch", &colopts);
if (!strcmp(var, "color.branch")) {
branch_use_color = git_config_colorbool(var, value);
return 0;
}
- if (!prefixcmp(var, "color.branch.")) {
+ if (starts_with(var, "color.branch.")) {
int slot = parse_branch_color_slot(var, 13);
if (slot < 0)
return 0;
@@ -868,7 +868,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
if (!strcmp(head, "HEAD")) {
detached = 1;
} else {
- if (prefixcmp(head, "refs/heads/"))
+ if (!starts_with(head, "refs/heads/"))
die(_("HEAD not found below refs/heads!"));
head += 11;
}
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 904fd715f0..5df3837e31 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -781,7 +781,7 @@ static int switch_branches(const struct checkout_opts *opts,
if (!(flag & REF_ISSYMREF))
old.path = NULL;
- if (old.path && !prefixcmp(old.path, "refs/heads/"))
+ if (old.path && starts_with(old.path, "refs/heads/"))
old.name = old.path + strlen("refs/heads/");
if (!new->name) {
@@ -816,7 +816,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
return 0;
}
- if (!prefixcmp(var, "submodule."))
+ if (starts_with(var, "submodule."))
return parse_submodule_config_option(var, value);
return git_xmerge_config(var, value, NULL);
@@ -1151,9 +1151,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
const char *argv0 = argv[0];
if (!argc || !strcmp(argv0, "--"))
die (_("--track needs a branch name"));
- if (!prefixcmp(argv0, "refs/"))
+ if (starts_with(argv0, "refs/"))
argv0 += 5;
- if (!prefixcmp(argv0, "remotes/"))
+ if (starts_with(argv0, "remotes/"))
argv0 += 8;
argv0 = strchr(argv0, '/');
if (!argv0 || !argv0[1])
diff --git a/builtin/clean.c b/builtin/clean.c
index 615cd57caf..2f26297142 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -100,7 +100,7 @@ static int parse_clean_color_slot(const char *var)
static int git_clean_config(const char *var, const char *value, void *cb)
{
- if (!prefixcmp(var, "column."))
+ if (starts_with(var, "column."))
return git_column_config(var, value, "clean", &colopts);
/* honors the color.interactive* config variables which also
@@ -109,7 +109,7 @@ static int git_clean_config(const char *var, const char *value, void *cb)
clean_use_color = git_config_colorbool(var, value);
return 0;
}
- if (!prefixcmp(var, "color.interactive.")) {
+ if (starts_with(var, "color.interactive.")) {
int slot = parse_clean_color_slot(var +
strlen("color.interactive."));
if (slot < 0)
diff --git a/builtin/clone.c b/builtin/clone.c
index 874e0fd0b6..ec4d1cd2bb 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -508,9 +508,9 @@ static void write_followtags(const struct ref *refs, const char *msg)
{
const struct ref *ref;
for (ref = refs; ref; ref = ref->next) {
- if (prefixcmp(ref->name, "refs/tags/"))
+ if (!starts_with(ref->name, "refs/tags/"))
continue;
- if (!suffixcmp(ref->name, "^{}"))
+ if (ends_with(ref->name, "^{}"))
continue;
if (!has_sha1_file(ref->old_sha1))
continue;
@@ -578,7 +578,7 @@ static void update_remote_refs(const struct ref *refs,
static void update_head(const struct ref *our, const struct ref *remote,
const char *msg)
{
- if (our && !prefixcmp(our->name, "refs/heads/")) {
+ if (our && starts_with(our->name, "refs/heads/")) {
/* Local default branch link */
create_symref("HEAD", our->name, NULL);
if (!option_bare) {
@@ -625,7 +625,7 @@ static int checkout(void)
if (advice_detached_head)
detach_advice(sha1_to_hex(sha1));
} else {
- if (prefixcmp(head, "refs/heads/"))
+ if (!starts_with(head, "refs/heads/"))
die(_("HEAD not found below refs/heads!"));
}
free(head);
diff --git a/builtin/column.c b/builtin/column.c
index e125a55fc9..75818520e1 100644
--- a/builtin/column.c
+++ b/builtin/column.c
@@ -34,7 +34,7 @@ int cmd_column(int argc, const char **argv, const char *prefix)
};
/* This one is special and must be the first one */
- if (argc > 1 && !prefixcmp(argv[1], "--command=")) {
+ if (argc > 1 && starts_with(argv[1], "--command=")) {
command = argv[1] + 10;
git_config(column_config, (void *)command);
} else
diff --git a/builtin/commit.c b/builtin/commit.c
index f4ff75d684..3767478c6d 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -733,7 +733,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
eol = nl - sb.buf;
else
eol = sb.len;
- if (!prefixcmp(sb.buf + previous, "\nConflicts:\n")) {
+ if (starts_with(sb.buf + previous, "\nConflicts:\n")) {
ignore_footer = sb.len - previous;
break;
}
@@ -904,7 +904,7 @@ static int rest_is_empty(struct strbuf *sb, int start)
eol = sb->len;
if (strlen(sign_off_header) <= eol - i &&
- !prefixcmp(sb->buf + i, sign_off_header)) {
+ starts_with(sb->buf + i, sign_off_header)) {
i = eol;
continue;
}
@@ -1183,7 +1183,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
{
struct wt_status *s = cb;
- if (!prefixcmp(k, "column."))
+ if (starts_with(k, "column."))
return git_column_config(k, v, "status", &s->colopts);
if (!strcmp(k, "status.submodulesummary")) {
int is_bool;
@@ -1211,7 +1211,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
s->display_comment_prefix = git_config_bool(k, v);
return 0;
}
- if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
+ if (starts_with(k, "status.color.") || starts_with(k, "color.status.")) {
int slot = parse_status_slot(k, 13);
if (slot < 0)
return 0;
@@ -1377,7 +1377,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,
head = resolve_ref_unsafe("HEAD", junk_sha1, 0, NULL);
printf("[%s%s ",
- !prefixcmp(head, "refs/heads/") ?
+ starts_with(head, "refs/heads/") ?
head + 11 :
!strcmp(head, "HEAD") ?
_("detached HEAD") :
diff --git a/builtin/describe.c b/builtin/describe.c
index 6f62109887..7db43dae1b 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -141,7 +141,7 @@ static void add_to_known_names(const char *path,
static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
- int is_tag = !prefixcmp(path, "refs/tags/");
+ int is_tag = starts_with(path, "refs/tags/");
unsigned char peeled[20];
int is_annotated, prio;
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index ea6305258d..b8d8a3aaf9 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -476,7 +476,7 @@ static void handle_tag(const char *name, struct tag *tag)
}
}
- if (!prefixcmp(name, "refs/tags/"))
+ if (starts_with(name, "refs/tags/"))
name += 10;
printf("tag %s\nfrom :%d\n%.*s%sdata %d\n%.*s\n",
name, tagged_mark,
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index c8e858232a..10fcdc2ff2 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -48,11 +48,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
for (i = 1; i < argc && *argv[i] == '-'; i++) {
const char *arg = argv[i];
- if (!prefixcmp(arg, "--upload-pack=")) {
+ if (starts_with(arg, "--upload-pack=")) {
args.uploadpack = arg + 14;
continue;
}
- if (!prefixcmp(arg, "--exec=")) {
+ if (starts_with(arg, "--exec=")) {
args.uploadpack = arg + 7;
continue;
}
@@ -85,7 +85,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
args.verbose = 1;
continue;
}
- if (!prefixcmp(arg, "--depth=")) {
+ if (starts_with(arg, "--depth=")) {
args.depth = strtol(arg + 8, NULL, 0);
continue;
}
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 3d978eb58e..e3ac84a0dd 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -192,7 +192,7 @@ static void find_non_local_tags(struct transport *transport,
for_each_ref(add_existing, &existing_refs);
for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
- if (prefixcmp(ref->name, "refs/tags/"))
+ if (!starts_with(ref->name, "refs/tags/"))
continue;
/*
@@ -201,7 +201,7 @@ static void find_non_local_tags(struct transport *transport,
* to fetch then we can mark the ref entry in the list
* as one to ignore by setting util to NULL.
*/
- if (!suffixcmp(ref->name, "^{}")) {
+ if (ends_with(ref->name, "^{}")) {
if (item && !has_sha1_file(ref->old_sha1) &&
!will_fetch(head, ref->old_sha1) &&
!has_sha1_file(item->util) &&
@@ -431,7 +431,7 @@ static int update_local_ref(struct ref *ref,
}
if (!is_null_sha1(ref->old_sha1) &&
- !prefixcmp(ref->name, "