Merge branch 'ls/p4-retry-thrice'
[gitweb.git] / builtin / index-pack.c
index d450a6ada2a247fc316caada8820241fdf975e0f..f4b87c6c9f901e5834ce9e50db089fb487c6eafc 100644 (file)
@@ -787,13 +787,15 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
                        const unsigned char *sha1)
 {
        void *new_data = NULL;
-       int collision_test_needed;
+       int collision_test_needed = 0;
 
        assert(data || obj_entry);
 
-       read_lock();
-       collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);
-       read_unlock();
+       if (startup_info->have_repository) {
+               read_lock();
+               collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);
+               read_unlock();
+       }
 
        if (collision_test_needed && !data) {
                read_lock();