remote-curl: pass ref SHA-1 to fetch-pack as well
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 5 Dec 2013 13:02:49 +0000 (20:02 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Dec 2013 00:14:18 +0000 (16:14 -0800)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch-pack.c
remote-curl.c
index 927424b6b8feaded0c13fd8e184e735e3ff9a00e..aa6e5967e7acefc4206867747104c6d7d4bdf7db 100644 (file)
@@ -13,6 +13,13 @@ static void add_sought_entry_mem(struct ref ***sought, int *nr, int *alloc,
                                 const char *name, int namelen)
 {
        struct ref *ref = xcalloc(1, sizeof(*ref) + namelen + 1);
+       unsigned char sha1[20];
+
+       if (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {
+               hashcpy(ref->old_sha1, sha1);
+               name += 41;
+               namelen -= 41;
+       }
 
        memcpy(ref->name, name, namelen);
        ref->name[namelen] = '\0';
index 222210fd31c7067ab5b5cae63b6f781b15a22d96..25d67308c3cd54f3c39d8b1ca4d70e1776e0d948 100644 (file)
@@ -719,7 +719,8 @@ static int fetch_git(struct discovery *heads,
                struct ref *ref = to_fetch[i];
                if (!ref->name || !*ref->name)
                        die("cannot fetch by sha1 over smart http");
-               packet_buf_write(&preamble, "%s\n", ref->name);
+               packet_buf_write(&preamble, "%s %s\n",
+                                sha1_to_hex(ref->old_sha1), ref->name);
        }
        packet_buf_flush(&preamble);