Merge branch 'dw/subtree-split-do-not-drop-merge'
[gitweb.git] / builtin / fetch-pack.c
index 4a6b340ab67622a1e0c57a2bd38e2de4f1ad91a5..9b2a514e1d787784c2fac8d844d58013b6091aa6 100644 (file)
@@ -14,12 +14,14 @@ 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;
+       struct object_id oid;
+       const int chunksz = GIT_SHA1_HEXSZ + 1;
+
+       if (namelen > chunksz && name[chunksz - 1] == ' ' &&
+               !get_oid_hex(name, &oid)) {
+               oidcpy(&ref->old_oid, &oid);
+               name += chunksz;
+               namelen -= chunksz;
        }
 
        memcpy(ref->name, name, namelen);
@@ -156,7 +158,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
                else {
                        /* read from stdin one ref per line, until EOF */
                        struct strbuf line = STRBUF_INIT;
-                       while (strbuf_getline(&line, stdin, '\n') != EOF)
+                       while (strbuf_getline_lf(&line, stdin) != EOF)
                                add_sought_entry(&sought, &nr_sought, &alloc_sought, line.buf);
                        strbuf_release(&line);
                }
@@ -210,7 +212,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 
        while (ref) {
                printf("%s %s\n",
-                      sha1_to_hex(ref->old_sha1), ref->name);
+                      oid_to_hex(&ref->old_oid), ref->name);
                ref = ref->next;
        }