From: Junio C Hamano Date: Mon, 1 Apr 2013 15:59:37 +0000 (-0700) Subject: Merge branch 'jk/pkt-line-cleanup' X-Git-Tag: v1.8.3-rc0~148 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e013bdab0fd388ec3d9faf2c3cd4ff3ce2a104d7;p=thirdparty%2Fgit.git Merge branch 'jk/pkt-line-cleanup' Clean up pkt-line API, implementation and its callers to make them more robust. * jk/pkt-line-cleanup: do not use GIT_TRACE_PACKET=3 in tests remote-curl: always parse incoming refs remote-curl: move ref-parsing code up in file remote-curl: pass buffer straight to get_remote_heads teach get_remote_heads to read from a memory buffer pkt-line: share buffer/descriptor reading implementation pkt-line: provide a LARGE_PACKET_MAX static buffer pkt-line: move LARGE_PACKET_MAX definition from sideband pkt-line: teach packet_read_line to chomp newlines pkt-line: provide a generic reading function with options pkt-line: drop safe_write function pkt-line: move a misplaced comment write_or_die: raise SIGPIPE when we get EPIPE upload-archive: use argv_array to store client arguments upload-archive: do not copy repo name send-pack: prefer prefixcmp over memcmp in receive_status fetch-pack: fix out-of-bounds buffer offset in get_ack upload-pack: remove packet debugging harness upload-pack: do not add duplicate objects to shallow list upload-pack: use get_sha1_hex to parse "shallow" lines --- e013bdab0fd388ec3d9faf2c3cd4ff3ce2a104d7 diff --cc builtin/fetch-pack.c index 670e81fd99,03ed2caae3..aba4465552 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@@ -119,14 -100,11 +119,11 @@@ int cmd_fetch_pack(int argc, const cha /* in stateless RPC mode we use pkt-line to read * from stdin, until we get a flush packet */ - static char line[1000]; for (;;) { - int n = packet_read_line(0, line, sizeof(line)); - if (!n) + char *line = packet_read_line(0, NULL); + if (!line) break; - if (line[n-1] == '\n') - n--; - add_sought_entry_mem(&sought, &nr_sought, &alloc_sought, line, n); - string_list_append(&sought, xstrdup(line)); ++ add_sought_entry(&sought, &nr_sought, &alloc_sought, line); } } else { @@@ -147,10 -125,10 +144,10 @@@ args.verbose ? CONNECT_VERBOSE : 0); } - get_remote_heads(fd[0], &ref, 0, NULL); + get_remote_heads(fd[0], NULL, 0, &ref, 0, NULL); ref = fetch_pack(&args, fd, conn, ref, dest, - &sought, pack_lockfile_ptr); + sought, nr_sought, pack_lockfile_ptr); if (pack_lockfile) { printf("lock %s\n", pack_lockfile); fflush(stdout); diff --cc transport.c index eb9eb33e0f,62df466c1a..ba5d8afb1b --- a/transport.c +++ b/transport.c @@@ -535,9 -536,12 +535,9 @@@ static int fetch_refs_via_pack(struct t args.no_progress = !transport->progress; args.depth = data->options.depth; - for (i = 0; i < nr_heads; i++) - string_list_append(&sought, to_fetch[i]->name); - if (!data->got_remote_heads) { connect_setup(transport, 0, 0); - get_remote_heads(data->fd[0], &refs_tmp, 0, NULL); + get_remote_heads(data->fd[0], NULL, 0, &refs_tmp, 0, NULL); data->got_remote_heads = 1; }