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 /upload-pack.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 'upload-pack.c')
-rw-r--r-- | upload-pack.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/upload-pack.c b/upload-pack.c index c989a737f9..dafd0e94d1 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -394,7 +394,7 @@ static int get_common_commits(void) got_other = 0; continue; } - if (!prefixcmp(line, "have ")) { + if (starts_with(line, "have ")) { switch (got_sha1(line+5, sha1)) { case -1: /* they have what we do not */ got_other = 1; @@ -540,7 +540,7 @@ static void receive_needs(void) if (!line) break; - if (!prefixcmp(line, "shallow ")) { + if (starts_with(line, "shallow ")) { unsigned char sha1[20]; struct object *object; if (get_sha1_hex(line + 8, sha1)) @@ -556,14 +556,14 @@ static void receive_needs(void) } continue; } - if (!prefixcmp(line, "deepen ")) { + if (starts_with(line, "deepen ")) { char *end; depth = strtol(line + 7, &end, 0); if (end == line + 7 || depth <= 0) die("Invalid deepen: %s", line); continue; } - if (prefixcmp(line, "want ") || + if (!starts_with(line, "want ") || get_sha1_hex(line+5, sha1_buf)) die("git upload-pack: protocol error, " "expected to get sha, not '%s'", line); @@ -815,7 +815,7 @@ int main(int argc, char **argv) strict = 1; continue; } - if (!prefixcmp(arg, "--timeout=")) { + if (starts_with(arg, "--timeout=")) { timeout = atoi(arg+10); daemon_mode = 1; continue; |