strbuf_release(&packname);
        /* Make objects we just wrote available to ourselves */
-       reprepare_packed_git();
+       reprepare_packed_git(the_repository);
  }
  
 -static int already_written(struct bulk_checkin_state *state, unsigned char sha1[])
 +static int already_written(struct bulk_checkin_state *state, struct object_id *oid)
  {
        int i;
  
 
        }
  
        while (1) {
-               if (find_pack_entry(real->hash, &e))
 -              if (find_pack_entry(the_repository, real, &e))
++              if (find_pack_entry(the_repository, real->hash, &e))
                        break;
  
 +              if (flags & OBJECT_INFO_IGNORE_LOOSE)
 +                      return -1;
 +
                /* Most likely it's a loose object. */
 -              if (!sha1_loose_object_info(the_repository, real, oi, flags))
 +              if (!sha1_loose_object_info(the_repository, real->hash, oi, flags))
                        return 0;
  
                /* Not a loose object; someone else may have just packed it. */
 -              reprepare_packed_git(the_repository);
 -              if (find_pack_entry(the_repository, real, &e))
 -                      break;
 +              if (!(flags & OBJECT_INFO_QUICK)) {
-                       reprepare_packed_git();
-                       if (find_pack_entry(real->hash, &e))
++                      reprepare_packed_git(the_repository);
++                      if (find_pack_entry(the_repository, real->hash, &e))
 +                              break;
 +              }
  
                /* Check if it is a missing object */
                if (fetch_if_missing && repository_format_partial_clone &&