Merge branch 'nd/clone-local-with-colon'
authorJonathan Nieder <jrnieder@gmail.com>
Mon, 14 Oct 2013 18:06:57 +0000 (11:06 -0700)
committerJonathan Nieder <jrnieder@gmail.com>
Mon, 14 Oct 2013 18:06:57 +0000 (11:06 -0700)
* nd/clone-local-with-colon:
clone: tighten "local paths with colons" check a bit

1  2 
connect.c
diff --combined connect.c
index a80ebd316c34bb0f0cf3d5a04c33123bb2847421,3c6300a21b9b70d2db4adc898be86ab06eb17e6c..40868610ab1c02d10cc7cdc927fdf97a5e010414
+++ b/connect.c
@@@ -5,7 -5,6 +5,7 @@@
  #include "refs.h"
  #include "run-command.h"
  #include "remote.h"
 +#include "connect.h"
  #include "url.h"
  
  static char *server_capabilities;
@@@ -63,8 -62,8 +63,8 @@@ static void die_initial_contact(int got
  /*
   * Read all the refs from the other end
   */
 -struct ref **get_remote_heads(int in, struct ref **list,
 -                            unsigned int flags,
 +struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
 +                            struct ref **list, unsigned int flags,
                              struct extra_have_objects *extra_have)
  {
        int got_at_least_one_head = 0;
        for (;;) {
                struct ref *ref;
                unsigned char old_sha1[20];
 -              static char buffer[1000];
                char *name;
                int len, name_len;
 +              char *buffer = packet_buffer;
  
 -              len = packet_read(in, buffer, sizeof(buffer));
 +              len = packet_read(in, &src_buf, &src_len,
 +                                packet_buffer, sizeof(packet_buffer),
 +                                PACKET_READ_GENTLE_ON_EOF |
 +                                PACKET_READ_CHOMP_NEWLINE);
                if (len < 0)
                        die_initial_contact(got_at_least_one_head);
  
                if (!len)
                        break;
 -              if (buffer[len-1] == '\n')
 -                      buffer[--len] = 0;
  
                if (len > 4 && !prefixcmp(buffer, "ERR "))
                        die("remote error: %s", buffer + 4);
@@@ -552,7 -550,7 +552,7 @@@ struct child_process *git_connect(int f
        path = strchr(end, c);
        if (path && !has_dos_drive_prefix(end)) {
                if (c == ':') {
-                       if (path < strchrnul(host, '/')) {
+                       if (host != url || path < strchrnul(host, '/')) {
                                protocol = PROTO_SSH;
                                *path++ = '\0';
                        } else /* '/' in the host part, assume local path */