diff options
author | Christian Couder <chriscool@tuxfamily.org> | 2013-11-30 21:55:40 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-12-05 14:13:21 -0800 |
commit | 59556548230e617b837343c2c07e357e688e2ca4 (patch) | |
tree | 5e66894c3d666f0fdc39aaf79de554dfeb7d0e36 /http.c | |
parent | 956623157f828b2b4fd91a9bc5e78ba8e42437d9 (diff) | |
download | git-59556548230e617b837343c2c07e357e688e2ca4.tar.gz |
replace {pre,suf}fixcmp() with {starts,ends}_with()cc/starts-n-ends-with
Leaving only the function definitions and declarations so that any
new topic in flight can still make use of the old functions, replace
existing uses of the prefixcmp() and suffixcmp() with new API
functions.
The change can be recreated by mechanically applying this:
$ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
grep -v strbuf\\.c |
xargs perl -pi -e '
s|!prefixcmp\(|starts_with\(|g;
s|prefixcmp\(|!starts_with\(|g;
s|!suffixcmp\(|ends_with\(|g;
s|suffixcmp\(|!ends_with\(|g;
'
on the result of preparatory changes in this series.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -460,7 +460,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth) credential_from_url(&http_auth, url); if (!ssl_cert_password_required && getenv("GIT_SSL_CERT_PASSWORD_PROTECTED") && - !prefixcmp(url, "https://")) + starts_with(url, "https://")) ssl_cert_password_required = 1; } @@ -994,7 +994,7 @@ static int update_url_from_redirect(struct strbuf *base, if (!strcmp(asked, got->buf)) return 0; - if (prefixcmp(asked, base->buf)) + if (!starts_with(asked, base->buf)) die("BUG: update_url_from_redirect: %s is not a superset of %s", asked, base->buf); @@ -1100,7 +1100,7 @@ int http_fetch_ref(const char *base, struct ref *ref) strbuf_rtrim(&buffer); if (buffer.len == 40) ret = get_sha1_hex(buffer.buf, ref->old_sha1); - else if (!prefixcmp(buffer.buf, "ref: ")) { + else if (starts_with(buffer.buf, "ref: ")) { ref->symref = xstrdup(buffer.buf + 5); ret = 0; } @@ -1201,8 +1201,8 @@ int http_get_info_packs(const char *base_url, struct packed_git **packs_head) case 'P': i++; if (i + 52 <= buf.len && - !prefixcmp(data + i, " pack-") && - !prefixcmp(data + i + 46, ".pack\n")) { + starts_with(data + i, " pack-") && + starts_with(data + i + 46, ".pack\n")) { get_sha1_hex(data + i + 6, sha1); fetch_and_setup_pack_index(packs_head, sha1, base_url); |