builtin-fsck: move away from object-refs to fsck_walk
[gitweb.git] / builtin-pack-objects.c
index 5765d02f54d7a7b8b7b463c15b48d151858eeb87..d3efeff03f89cc0f4d0da463ddf878c28effb31e 100644 (file)
@@ -445,7 +445,7 @@ static unsigned long write_object(struct sha1file *f,
                        /* nothing */;
                deflateEnd(&stream);
                datalen = stream.total_out;
-               deflateEnd(&stream);
+
                /*
                 * The object header is a byte of 'type' followed by zero or
                 * more bytes of length.
@@ -1670,11 +1670,10 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
                p[i].processed = processed;
                p[i].working = 1;
                p[i].data_ready = 0;
-               pthread_mutex_init(&p[i].mutex, NULL);
-               pthread_cond_init(&p[i].cond, NULL);
 
                /* try to split chunks on "path" boundaries */
-               while (sub_size < list_size && list[sub_size]->hash &&
+               while (sub_size && sub_size < list_size &&
+                      list[sub_size]->hash &&
                       list[sub_size]->hash == list[sub_size-1]->hash)
                        sub_size++;
 
@@ -1690,6 +1689,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
        for (i = 0; i < delta_search_threads; i++) {
                if (!p[i].list_size)
                        continue;
+               pthread_mutex_init(&p[i].mutex, NULL);
+               pthread_cond_init(&p[i].cond, NULL);
                ret = pthread_create(&p[i].thread, NULL,
                                     threaded_find_deltas, &p[i]);
                if (ret)
@@ -2013,7 +2014,7 @@ static void get_object_list(int ac, const char **av)
 
        while (fgets(line, sizeof(line), stdin) != NULL) {
                int len = strlen(line);
-               if (line[len - 1] == '\n')
+               if (len && line[len - 1] == '\n')
                        line[--len] = 0;
                if (!len)
                        break;