Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
upload-pack: use skip_prefix() instead of starts_with()
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 12 Jun 2016 10:53:49 +0000
(17:53 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 13 Jun 2016 21:38:16 +0000
(14:38 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (from parent 1:
873700c
)
diff --git
a/upload-pack.c
b/upload-pack.c
index 73a8b28f57a6b4c39095e5bd52d55e17e138607a..fa7ce092e77035974596b0879002bb093b300679 100644
(file)
--- a/
upload-pack.c
+++ b/
upload-pack.c
@@
-276,7
+276,7
@@
static void create_pack_file(void)
die("git upload-pack: %s", abort_msg);
}
die("git upload-pack: %s", abort_msg);
}
-static int got_sha1(char *hex, unsigned char *sha1)
+static int got_sha1(c
onst c
har *hex, unsigned char *sha1)
{
struct object *o;
int we_knew_they_have = 0;
{
struct object *o;
int we_knew_they_have = 0;
@@
-382,6
+382,8
@@
static int get_common_commits(void)
for (;;) {
char *line = packet_read_line(0, NULL);
for (;;) {
char *line = packet_read_line(0, NULL);
+ const char *arg;
+
reset_timeout();
if (!line) {
reset_timeout();
if (!line) {
@@
-403,8
+405,8
@@
static int get_common_commits(void)
got_other = 0;
continue;
}
got_other = 0;
continue;
}
- if (s
tarts_with(line, "have "
)) {
- switch (got_sha1(
line+5
, sha1)) {
+ if (s
kip_prefix(line, "have ", &arg
)) {
+ switch (got_sha1(
arg
, sha1)) {
case -1: /* they have what we do not */
got_other = 1;
if (multi_ack && ok_to_give_up()) {
case -1: /* they have what we do not */
got_other = 1;
if (multi_ack && ok_to_give_up()) {
@@
-620,14
+622,16
@@
static void receive_needs(void)
const char *features;
unsigned char sha1_buf[20];
char *line = packet_read_line(0, NULL);
const char *features;
unsigned char sha1_buf[20];
char *line = packet_read_line(0, NULL);
+ const char *arg;
+
reset_timeout();
if (!line)
break;
reset_timeout();
if (!line)
break;
- if (s
tarts_with(line, "shallow "
)) {
+ if (s
kip_prefix(line, "shallow ", &arg
)) {
unsigned char sha1[20];
struct object *object;
unsigned char sha1[20];
struct object *object;
- if (get_sha1_hex(
line + 8
, sha1))
+ if (get_sha1_hex(
arg
, sha1))
die("invalid shallow line: %s", line);
object = parse_object(sha1);
if (!object)
die("invalid shallow line: %s", line);
object = parse_object(sha1);
if (!object)
@@
-640,19
+644,19
@@
static void receive_needs(void)
}
continue;
}
}
continue;
}
- if (s
tarts_with(line, "deepen "
)) {
+ if (s
kip_prefix(line, "deepen ", &arg
)) {
char *end;
char *end;
- depth = strtol(
line + 7
, &end, 0);
- if (end ==
line + 7
|| depth <= 0)
+ depth = strtol(
arg
, &end, 0);
+ if (end ==
arg
|| depth <= 0)
die("Invalid deepen: %s", line);
continue;
}
die("Invalid deepen: %s", line);
continue;
}
- if (!s
tarts_with(line, "want "
) ||
- get_sha1_hex(
line+5
, sha1_buf))
+ if (!s
kip_prefix(line, "want ", &arg
) ||
+ get_sha1_hex(
arg
, sha1_buf))
die("git upload-pack: protocol error, "
"expected to get sha, not '%s'", line);
die("git upload-pack: protocol error, "
"expected to get sha, not '%s'", line);
- features =
line + 45
;
+ features =
arg + 40
;
if (parse_feature_request(features, "multi_ack_detailed"))
multi_ack = 2;
if (parse_feature_request(features, "multi_ack_detailed"))
multi_ack = 2;
@@
-859,7
+863,7
@@
int main(int argc, char **argv)
check_replace_refs = 0;
for (i = 1; i < argc; i++) {
check_replace_refs = 0;
for (i = 1; i < argc; i++) {
- char *arg = argv[i];
+ c
onst c
har *arg = argv[i];
if (arg[0] != '-')
break;
if (arg[0] != '-')
break;
@@
-875,8
+879,8
@@
int main(int argc, char **argv)
strict = 1;
continue;
}
strict = 1;
continue;
}
- if (s
tarts_with(arg, "--timeout="
)) {
- timeout = atoi(arg
+10
);
+ if (s
kip_prefix(arg, "--timeout=", &arg
)) {
+ timeout = atoi(arg);
daemon_mode = 1;
continue;
}
daemon_mode = 1;
continue;
}