object_as_type: set commit index
[gitweb.git] / object.c
index b2319f62468c76134e84c157c2035654b38e17fc..69fbbbf504d861fac42ee50bc04a49ede1f60028 100644 (file)
--- a/object.c
+++ b/object.c
@@ -163,6 +163,8 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
        if (obj->type == type)
                return obj;
        else if (obj->type == OBJ_NONE) {
+               if (type == OBJ_COMMIT)
+                       ((struct commit *)obj)->index = alloc_commit_index();
                obj->type = type;
                return obj;
        }