fsck: change functions to use object_id
[gitweb.git] / fetch-pack.c
index 655ee642564e3ada5b782dd6fa2d2c799f340978..5380b1b8c1c076f1db633e759ef07aa88cc1aae1 100644 (file)
@@ -256,14 +256,20 @@ static int find_common(struct fetch_pack_args *args,
        int got_ready = 0;
        struct strbuf req_buf = STRBUF_INIT;
        size_t state_len = 0;
+       struct each_ref_fn_sha1_adapter wrapped_rev_list_insert_ref =
+               {rev_list_insert_ref, NULL};
 
        if (args->stateless_rpc && multi_ack == 1)
                die("--stateless-rpc requires multi_ack_detailed");
-       if (marked)
-               for_each_ref(clear_marks, NULL);
+       if (marked) {
+               struct each_ref_fn_sha1_adapter wrapped_clear_marks =
+                       {clear_marks, NULL};
+
+               for_each_ref(each_ref_fn_adapter, &wrapped_clear_marks);
+       }
        marked = 1;
 
-       for_each_ref(rev_list_insert_ref, NULL);
+       for_each_ref(each_ref_fn_adapter, &wrapped_rev_list_insert_ref);
        for_each_alternate_ref(insert_one_alternate_ref, NULL);
 
        fetching = 0;
@@ -544,16 +550,19 @@ static void filter_refs(struct fetch_pack_args *args,
        /* Append unmatched requests to the list */
        if (allow_tip_sha1_in_want) {
                for (i = 0; i < nr_sought; i++) {
+                       unsigned char sha1[20];
+
                        ref = sought[i];
                        if (ref->matched)
                                continue;
-                       if (get_sha1_hex(ref->name, ref->old_sha1))
+                       if (get_sha1_hex(ref->name, sha1) ||
+                           ref->name[40] != '\0' ||
+                           hashcmp(sha1, ref->old_sha1))
                                continue;
 
                        ref->matched = 1;
-                       *newtail = ref;
-                       ref->next = NULL;
-                       newtail = &ref->next;
+                       *newtail = copy_ref(ref);
+                       newtail = &(*newtail)->next;
                }
        }
        *refs = newlist;
@@ -596,7 +605,10 @@ static int everything_local(struct fetch_pack_args *args,
        }
 
        if (!args->depth) {
-               for_each_ref(mark_complete, NULL);
+               struct each_ref_fn_sha1_adapter wrapped_mark_complete =
+                       {mark_complete, NULL};
+
+               for_each_ref(each_ref_fn_adapter, &wrapped_mark_complete);
                for_each_alternate_ref(mark_alternate_complete, NULL);
                commit_list_sort_by_date(&complete);
                if (cutoff)
@@ -625,7 +637,6 @@ static int everything_local(struct fetch_pack_args *args,
 
        for (retval = 1, ref = *refs; ref ; ref = ref->next) {
                const unsigned char *remote = ref->old_sha1;
-               unsigned char local[20];
                struct object *o;
 
                o = lookup_object(remote);
@@ -638,8 +649,6 @@ static int everything_local(struct fetch_pack_args *args,
                                ref->name);
                        continue;
                }
-
-               hashcpy(ref->new_sha1, local);
                if (!args->verbose)
                        continue;
                fprintf(stderr,