Merge branch 'nd/upload-pack-shallow-must-be-commit'
authorJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2013 16:15:44 +0000 (08:15 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2013 16:15:44 +0000 (08:15 -0800)
A minor consistency check patch that does not have much relevance
to the real world.

* nd/upload-pack-shallow-must-be-commit:
upload-pack: only accept commits from "shallow" line

1  2 
upload-pack.c
diff --combined upload-pack.c
index 6142421ea1172f7fe6b57486a4f41b81d92bab85,8c715354e70e7577d92c0591ac9573cb53e2e45b..95d83135ae95b2fa7980c69cbd7b49e3a6ff2d0a
@@@ -603,6 -603,8 +603,8 @@@ static void receive_needs(void
                        object = parse_object(sha1);
                        if (!object)
                                die("did not find object for %s", line);
+                       if (object->type != OBJ_COMMIT)
+                               die("invalid shallow object %s", sha1_to_hex(sha1));
                        object->flags |= CLIENT_SHALLOW;
                        add_object_array(object, NULL, &shallows);
                        continue;
@@@ -727,7 -729,12 +729,7 @@@ static int send_ref(const char *refname
                " include-tag multi_ack_detailed";
        struct object *o = lookup_unknown_object(sha1);
        const char *refname_nons = strip_namespace(refname);
 -
 -      if (o->type == OBJ_NONE) {
 -              o->type = sha1_object_info(sha1, NULL);
 -              if (o->type < 0)
 -                  die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
 -      }
 +      unsigned char peeled[20];
  
        if (capabilities)
                packet_write(1, "%s %s%c%s%s agent=%s\n",
                o->flags |= OUR_REF;
                nr_our_refs++;
        }
 -      if (o->type == OBJ_TAG) {
 -              o = deref_tag_noverify(o);
 -              if (o)
 -                      packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname_nons);
 -      }
 +      if (!peel_ref(refname, peeled))
 +              packet_write(1, "%s %s^{}\n", sha1_to_hex(peeled), refname_nons);
        return 0;
  }