diff.c: allow to pass more flags to diff_populate_filespec
[gitweb.git] / object.c
index b2319f62468c76134e84c157c2035654b38e17fc..a16b9f9e936d060ba190b6c7e82ff5f25795f490 100644 (file)
--- a/object.c
+++ b/object.c
@@ -50,18 +50,7 @@ int type_from_string(const char *str)
  */
 static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
 {
-       unsigned int hash;
-
-       /*
-        * Since the sha1 is essentially random, we just take the
-        * required number of bits directly from the first
-        * sizeof(unsigned int) bytes of sha1.  First we have to copy
-        * the bytes into a properly aligned integer.  If we cared
-        * about getting consistent results across architectures, we
-        * would have to call ntohl() here, too.
-        */
-       memcpy(&hash, sha1, sizeof(unsigned int));
-       return hash & (n - 1);
+       return sha1hash(sha1) & (n - 1);
 }
 
 /*
@@ -163,6 +152,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;
        }