]> git.ipfire.org Git - thirdparty/git.git/blobdiff - connect.c
bash: add '--merge' to 'git reset'
[thirdparty/git.git] / connect.c
index 67d2cd86a89a92f8f75baa7ae5e820ac3150f3b4..2f55ad2c256bc01b3062b99251af4386eef5af22 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -70,6 +70,9 @@ struct ref **get_remote_heads(int in, struct ref **list,
                if (buffer[len-1] == '\n')
                        buffer[--len] = 0;
 
+               if (len > 4 && !prefixcmp(buffer, "ERR "))
+                       die("remote error: %s", buffer + 4);
+
                if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
                        die("protocol error: expected sha/ref, got '%s'", buffer);
                name = buffer + 41;
@@ -90,9 +93,8 @@ struct ref **get_remote_heads(int in, struct ref **list,
                        continue;
                if (nr_match && !path_match(name, nr_match, match))
                        continue;
-               ref = alloc_ref(name_len + 1);
+               ref = alloc_ref(buffer + 41);
                hashcpy(ref->old_sha1, old_sha1);
-               memcpy(ref->name, buffer + 41, name_len + 1);
                *list = ref;
                list = &ref->next;
        }
@@ -478,8 +480,8 @@ char *get_port(char *host)
        char *p = strchr(host, ':');
 
        if (p) {
-               strtol(p+1, &end, 10);
-               if (*end == '\0') {
+               long port = strtol(p + 1, &end, 10);
+               if (end != p + 1 && *end == '\0' && 0 <= port && port < 65536) {
                        *p = '\0';
                        return p+1;
                }