Skip to content

Commit 72fbf05

Browse files
author
Charlie Somerville
committed
trailer: use git__prefixcmp instead of starts_with
1 parent 1372261 commit 72fbf05

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/trailer.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,6 @@ static int last_line(const char *buf, size_t len)
6565
return 0;
6666
}
6767

68-
static bool starts_with(const char *str, const char *prefix)
69-
{
70-
size_t str_len = strlen(str);
71-
size_t prefix_len = strlen(prefix);
72-
73-
if (prefix_len > str_len) {
74-
return false;
75-
}
76-
77-
return memcmp(str, prefix, prefix_len) == 0;
78-
}
79-
8068
/*
8169
* If the given line is of the form
8270
* "<token><optional whitespace><separator>..." or "<separator>...", return the
@@ -136,7 +124,7 @@ static int ignore_non_trailer(const char *buf, size_t len)
136124
if (!boc)
137125
boc = bol;
138126
/* otherwise, it is just continuing */
139-
} else if (starts_with(buf + bol, "Conflicts:\n")) {
127+
} else if (git__prefixcmp(buf + bol, "Conflicts:\n") == 0) {
140128
in_old_conflicts_block = 1;
141129
if (!boc)
142130
boc = bol;
@@ -161,7 +149,7 @@ static int find_patch_start(const char *str)
161149
const char *s;
162150

163151
for (s = str; *s; s = next_line(s)) {
164-
if (starts_with(s, "---"))
152+
if (git__prefixcmp(s, "---") == 0)
165153
return s - str;
166154
}
167155

@@ -227,7 +215,7 @@ static int find_trailer_start(const char *buf, size_t len)
227215
only_spaces = 0;
228216

229217
for (p = git_generated_prefixes; *p; p++) {
230-
if (starts_with(bol, *p)) {
218+
if (git__prefixcmp(bol, *p) == 0) {
231219
trailer_lines++;
232220
possible_continuation_lines = 0;
233221
recognized_prefix = 1;

0 commit comments

Comments
 (0)