git-p4: add failing test for P4EDITOR handling
[gitweb.git] / fetch-pack.c
index 7487aa730630e8b45874e3487db8e71c05e1968c..48526aa54bbb8458a10fc178f4fa5a429b77bc87 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "lockfile.h"
 #include "refs.h"
 #include "pkt-line.h"
 #include "commit.h"
@@ -543,16 +544,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;
@@ -624,7 +628,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);
@@ -637,8 +640,6 @@ static int everything_local(struct fetch_pack_args *args,
                                ref->name);
                        continue;
                }
-
-               hashcpy(ref->new_sha1, local);
                if (!args->verbose)
                        continue;
                fprintf(stderr,