Merge branch 'jk/pkt-line-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2013 15:59:37 +0000 (08:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2013 15:59:37 +0000 (08:59 -0700)
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

1  2 
builtin/fetch-pack.c
cache.h
daemon.c
fetch-pack.c
transport.c
upload-pack.c
index 670e81fd995953bff9c29cc6fab99d03f1fee8b7,03ed2caae33886078b8182ef46c33f07cf3d56a0..aba44655524ff722d90de09760945f5f30088752
@@@ -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 {
                                   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 cache.h
Simple merge
diff --cc daemon.c
Simple merge
diff --cc fetch-pack.c
Simple merge
diff --cc transport.c
index eb9eb33e0f0f151156ca646bb998c538f2471d7f,62df466c1a82705c3e1d0cb21aa6f316710f0cfe..ba5d8afb1b04ba9d331c721fd9f730184fff2f23
@@@ -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;
        }
  
diff --cc upload-pack.c
Simple merge