summaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-02-20 01:53:29 -0800
committerJunio C Hamano <junkio@cox.net>2007-02-20 22:03:15 -0800
commitcc44c7655fe2dd0cfb46e841156634fe622df397 (patch)
tree6829fa96174f857c90e8baf966a2a8c7b924514a /upload-pack.c
parentcff0302c14522ba7b34265ee39f23e6321a4777d (diff)
downloadgit-cc44c7655fe2dd0cfb46e841156634fe622df397.tar.gz
Mechanical conversion to use prefixcmp()
This mechanically converts strncmp() to use prefixcmp(), but only when the parameters match specific patterns, so that they can be verified easily. Leftover from this will be fixed in a separate step, including idiotic conversions like if (!strncmp("foo", arg, 3)) => if (!(-prefixcmp(arg, "foo"))) This was done by using this script in px.perl #!/usr/bin/perl -i.bak -p if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) { s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|; } if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) { s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|; } and running: $ git grep -l strncmp -- '*.c' | xargs perl px.perl Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 3648aae1a7..d7876cade9 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -455,7 +455,7 @@ static int get_common_commits(void)
continue;
}
len = strip(line, len);
- if (!strncmp(line, "have ", 5)) {
+ if (!prefixcmp(line, "have ")) {
switch (got_sha1(line+5, sha1)) {
case -1: /* they have what we do not */
if (multi_ack && ok_to_give_up())
@@ -502,7 +502,7 @@ static void receive_needs(void)
if (!len)
break;
- if (!strncmp("shallow ", line, 8)) {
+ if (!(-prefixcmp(line, "shallow "))) {
unsigned char sha1[20];
struct object *object;
use_thin_pack = 0;
@@ -515,7 +515,7 @@ static void receive_needs(void)
add_object_array(object, NULL, &shallows);
continue;
}
- if (!strncmp("deepen ", line, 7)) {
+ if (!(-prefixcmp(line, "deepen "))) {
char *end;
use_thin_pack = 0;
depth = strtol(line + 7, &end, 0);
@@ -523,7 +523,7 @@ static void receive_needs(void)
die("Invalid deepen: %s", line);
continue;
}
- if (strncmp("want ", line, 5) ||
+ if ((-prefixcmp(line, "want ")) ||
get_sha1_hex(line+5, sha1_buf))
die("git-upload-pack: protocol error, "
"expected to get sha, not '%s'", line);
@@ -656,7 +656,7 @@ int main(int argc, char **argv)
strict = 1;
continue;
}
- if (!strncmp(arg, "--timeout=", 10)) {
+ if (!prefixcmp(arg, "--timeout=")) {
timeout = atoi(arg+10);
continue;
}