line |
true |
false |
branch |
97
|
0 |
5 |
if ((error = p_mmap(&map, sizeof(*hdr), GIT_PROT_READ, GIT_MAP_SHARED, pack->mwf.fd, 0)) < 0) |
104
|
0 |
5 |
if (hdr->hdr_signature != ntohl(PACK_SIGNATURE)) { |
109
|
0 |
5 |
if (!pack_version_ok(hdr->hdr_version)) { |
127
|
0 |
0 |
GIT_INIT_STRUCTURE_FROM_TEMPLATE( |
152
|
4 |
1 |
if (in_opts) |
156
|
0 |
5 |
GIT_ERROR_CHECK_ALLOC(idx); |
160
|
0 |
5 |
idx->mode = mode ? mode : GIT_PACK_FILE_MODE; |
163
|
5 |
0 |
if ((error = git_hash_ctx_init(&idx->hash_ctx, GIT_HASH_ALGORITHM_SHA1)) < 0 || |
|
5 |
0 |
if ((error = git_hash_ctx_init(&idx->hash_ctx, GIT_HASH_ALGORITHM_SHA1)) < 0 || |
164
|
5 |
0 |
(error = git_hash_ctx_init(&idx->trailer, GIT_HASH_ALGORITHM_SHA1)) < 0 || |
170
|
0 |
5 |
if (git_repository__fsync_gitdir) |
174
|
0 |
5 |
if (error < 0) |
179
|
0 |
5 |
if (fd < 0) |
185
|
0 |
5 |
if (error < 0) |
189
|
0 |
5 |
if ((error = git_mwindow_file_register(&idx->pack->mwf)) < 0) |
196
|
0 |
0 |
if (fd != -1) |
199
|
0 |
0 |
if (git_str_len(&tmp_path) > 0) |
202
|
0 |
0 |
if (idx->pack != NULL) |
222
|
0 |
2 |
GIT_ERROR_CHECK_ALLOC(delta); |
225
|
0 |
2 |
if (git_vector_insert(&idx->deltas, delta) < 0) |
237
|
0 |
43 |
if ((error = git_odb__format_object_header(&hdrlen, |
248
|
0 |
43 |
GIT_ASSERT_ARG(idx); |
249
|
0 |
43 |
GIT_ASSERT_ARG(stream); |
252
|
0 |
86 |
if ((read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf))) < 0) |
255
|
0 |
86 |
if (idx->do_verify) |
259
|
43 |
43 |
} while (read > 0); |
261
|
0 |
43 |
if (read < 0) |
272
|
0 |
2 |
GIT_ASSERT_ARG(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA); |
|
0 |
0 |
GIT_ASSERT_ARG(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA); |
274
|
2 |
0 |
if (type == GIT_OBJECT_REF_DELTA) { |
280
|
0 |
0 |
if (error < 0) |
292
|
0 |
4 |
GIT_ASSERT_ARG(stream); |
296
|
2 |
4 |
} while (read > 0); |
298
|
2 |
2 |
if (read < 0) |
312
|
45 |
45 |
while (size) { |
314
|
0 |
45 |
if (ptr == NULL) |
335
|
0 |
0 |
if ((!idx->odb || !git_odb_exists(idx->odb, oid)) && |
336
|
0 |
0 |
!git_oidmap_exists(idx->pack->idx_cache, oid) && |
339
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(dup); |
353
|
0 |
0 |
if (obj->type != GIT_OBJECT_BLOB && |
|
0 |
0 |
if (obj->type != GIT_OBJECT_BLOB && |
354
|
0 |
0 |
obj->type != GIT_OBJECT_TREE && |
355
|
0 |
0 |
obj->type != GIT_OBJECT_COMMIT && |
359
|
0 |
0 |
if (git_object__from_raw(&object, obj->data, obj->len, obj->type) < 0) { |
368
|
0 |
0 |
if ((expected = git_oidmap_get(idx->expected_oids, &object->cached.oid)) != NULL) { |
377
|
0 |
0 |
if (idx->odb && git_odb_exists(idx->odb, &object->cached.oid)) |
|
0 |
0 |
if (idx->odb && git_odb_exists(idx->odb, &object->cached.oid)) |
387
|
0 |
0 |
git_array_foreach(tree->entries, i, entry) |
|
0 |
0 |
git_array_foreach(tree->entries, i, entry) |
388
|
0 |
0 |
if (add_expected_oid(idx, &entry->oid) < 0) |
399
|
0 |
0 |
git_array_foreach(commit->parent_ids, i, parent_oid) |
|
0 |
0 |
git_array_foreach(commit->parent_ids, i, parent_oid) |
400
|
0 |
0 |
if (add_expected_oid(idx, parent_oid) < 0) |
403
|
0 |
0 |
if (add_expected_oid(idx, &commit->tree_id) < 0) |
412
|
0 |
0 |
if (add_expected_oid(idx, &tag->target) < 0) |
438
|
0 |
43 |
GIT_ERROR_CHECK_ALLOC(entry); |
441
|
0 |
43 |
GIT_ERROR_CHECK_ALLOC(pentry); |
443
|
0 |
43 |
if (git_hash_final(oid.id, &idx->hash_ctx)) { |
448
|
0 |
43 |
if (entry_start > UINT31_MAX) { |
455
|
0 |
43 |
if (idx->do_verify) { |
462
|
0 |
0 |
if ((error = check_object_connectivity(idx, &rawobj)) < 0) |
469
|
0 |
43 |
if (git_oidmap_exists(idx->pack->idx_cache, &pentry->sha1)) { |
475
|
0 |
43 |
if ((error = git_oidmap_set(idx->pack->idx_cache, &pentry->sha1, pentry)) < 0) { |
483
|
0 |
43 |
if (crc_object(&entry->crc, &idx->pack->mwf, entry_start, entry_size) < 0) |
487
|
0 |
43 |
if (git_vector_insert(&idx->objects, entry) < 0) |
490
|
5148 |
43 |
for (i = oid.id[0]; i < 256; ++i) { |
511
|
0 |
2 |
if (entry_start > UINT31_MAX) { |
527
|
0 |
2 |
if (git_vector_insert(&idx->objects, entry) < 0) |
530
|
134 |
2 |
for (i = entry->oid.id[0]; i < 256; ++i) { |
545
|
0 |
2 |
GIT_ERROR_CHECK_ALLOC(entry); |
547
|
0 |
2 |
if (git_odb__hashobj(&oid, obj) < 0) { |
553
|
0 |
2 |
GIT_ERROR_CHECK_ALLOC(pentry); |
560
|
0 |
2 |
if (crc_object(&entry->crc, &idx->pack->mwf, entry_start, entry_size) < 0) |
574
|
41 |
11 |
if (idx->progress_cb) |
586
|
0 |
91 |
if (size == 0) |
590
|
45 |
46 |
if (size >= GIT_OID_RAWSZ) { |
601
|
8 |
38 |
if (idx->inbuf_len + size <= GIT_OID_RAWSZ) { |
626
|
91 |
91 |
while (remaining_size > 0) { |
628
|
0 |
91 |
HANDLE_EINTR(nb, p_pwrite(idx->pack->mwf.fd, (void *)ptr, |
|
0 |
0 |
HANDLE_EINTR(nb, p_pwrite(idx->pack->mwf.fd, (void *)ptr, |
630
|
0 |
91 |
if (nb <= 0) |
643
|
0 |
91 |
if (write_at(idx, data, idx->pack->mwf.size, size) < 0) { |
732
|
84 |
47 |
if (idx->pack->mwf.size <= idx->off + 20) |
735
|
45 |
2 |
if (!idx->have_stream) { |
737
|
0 |
45 |
if (error == GIT_EBUFS) { |
741
|
0 |
45 |
if (error < 0) |
749
|
43 |
2 |
if (type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA) { |
|
0 |
43 |
if (type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA) { |
751
|
0 |
2 |
if (error == GIT_EBUFS) { |
755
|
0 |
2 |
if (error < 0) |
763
|
0 |
43 |
if (error < 0) |
771
|
0 |
45 |
if (error < 0) |
775
|
4 |
43 |
if (idx->have_delta) { |
782
|
2 |
45 |
if (error == GIT_EBUFS) |
789
|
0 |
45 |
if (error < 0) |
792
|
2 |
43 |
if (idx->have_delta) { |
798
|
0 |
45 |
if (error < 0) |
801
|
43 |
2 |
if (!idx->have_delta) { |
806
|
0 |
45 |
if ((error = do_progress_callback(idx, stats)) != 0) |
818
|
0 |
91 |
GIT_ASSERT_ARG(idx); |
819
|
0 |
91 |
GIT_ASSERT_ARG(data); |
820
|
0 |
91 |
GIT_ASSERT_ARG(stats); |
822
|
0 |
91 |
if ((error = append_to_pack(idx, data, size)) < 0) |
830
|
5 |
86 |
if (!idx->parsed_header) { |
833
|
0 |
5 |
if ((unsigned)idx->pack->mwf.size < sizeof(struct git_pack_header)) |
836
|
0 |
5 |
if ((error = parse_header(&idx->hdr, idx->pack)) < 0) |
843
|
5 |
0 |
if (idx->nr_objects <= git_indexer__max_objects) { |
850
|
0 |
5 |
if (git_oidmap_new(&idx->pack->idx_cache) < 0) |
854
|
0 |
5 |
if (git_vector_init(&idx->objects, total_objects, objects_cmp) < 0) |
857
|
0 |
5 |
if (git_vector_init(&idx->deltas, total_objects / 2, NULL) < 0) |
867
|
0 |
5 |
if ((error = do_progress_callback(idx, stats)) != 0) |
874
|
0 |
91 |
if ((error = git_mwindow_free_all(mwf)) < 0) |
877
|
131 |
5 |
while (stats->indexed_objects < idx->nr_objects) { |
878
|
86 |
45 |
if ((error = read_stream_object(idx, stats)) != 0) { |
879
|
86 |
0 |
if (error == GIT_EBUFS) |
899
|
380 |
0 |
while (slash > 0 && path->ptr[slash - 1] != '/') |
|
370 |
10 |
while (slash > 0 && path->ptr[slash - 1] != '/') |
902
|
0 |
10 |
if (git_str_grow(path, slash + 1 + strlen(prefix) + |
911
|
0 |
10 |
return git_str_oom(path) ? -1 : 0; |
938
|
0 |
0 |
if ((error = seek_back_trailer(idx)) < 0) |
943
|
0 |
0 |
if ((error = git_odb_read(&obj, idx->odb, id)) < 0) { |
952
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(entry); |
957
|
0 |
0 |
if ((error = git_packfile__object_header(&hdr_len, hdr, len, git_odb_object_type(obj))) < 0 || |
|
0 |
0 |
if ((error = git_packfile__object_header(&hdr_len, hdr, len, git_odb_object_type(obj))) < 0 || |
964
|
0 |
0 |
if ((error = git_zstream_deflatebuf(&buf, data, len)) < 0) |
968
|
0 |
0 |
if ((error = append_to_pack(idx, buf.ptr, buf.size)) < 0) |
977
|
0 |
0 |
if ((error = append_to_pack(idx, empty_checksum, checksum_size)) < 0) |
983
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(pentry); |
992
|
0 |
0 |
if (error) { |
1014
|
0 |
0 |
GIT_ASSERT(git_vector_length(&idx->deltas) > 0); |
1016
|
0 |
0 |
if (idx->odb == NULL) { |
1022
|
0 |
0 |
git_vector_foreach(&idx->deltas, i, delta) { |
1023
|
0 |
0 |
if (!delta) |
1028
|
0 |
0 |
if (error < 0) |
1031
|
0 |
0 |
if (type == GIT_OBJECT_REF_DELTA) { |
1037
|
0 |
0 |
if (!found_ref_delta) { |
1044
|
0 |
0 |
if (base_info == NULL) { |
1052
|
0 |
0 |
if (has_entry(idx, &base)) |
1055
|
0 |
0 |
if (inject_object(idx, &base) < 0) |
1070
|
4 |
3 |
while (idx->deltas.length > 0) { |
1073
|
4 |
4 |
git_vector_foreach(&idx->deltas, i, delta) { |
1076
|
2 |
2 |
if (!delta) |
1081
|
0 |
2 |
if ((error = git_packfile_unpack(&obj, idx->pack, &idx->off)) < 0) { |
1082
|
0 |
0 |
if (error == GIT_PASSTHROUGH) { |
1089
|
0 |
2 |
if (idx->do_verify && check_object_connectivity(idx, &obj) < 0) |
|
0 |
0 |
if (idx->do_verify && check_object_connectivity(idx, &obj) < 0) |
1093
|
0 |
2 |
if (hash_and_save(idx, &obj, delta->delta_off) < 0) |
1100
|
0 |
2 |
if ((progress_cb_result = do_progress_callback(idx, stats)) < 0) |
1109
|
2 |
2 |
if (!non_null) |
1112
|
0 |
2 |
if (!progressed && (fix_thin_pack(idx, stats) < 0)) { |
|
0 |
0 |
if (!progressed && (fix_thin_pack(idx, stats) < 0)) { |
1136
|
0 |
0 |
if (write_at(idx, &idx->hdr, 0, sizeof(struct git_pack_header)) < 0) |
1145
|
0 |
0 |
if (git_mwindow_free_all(mwf) < 0) |
1149
|
0 |
0 |
while (hashed < mwf->size) { |
1151
|
0 |
0 |
if (ptr == NULL) |
1177
|
0 |
5 |
if (!idx->parsed_header) { |
1183
|
0 |
5 |
if (idx->off + (ssize_t)checksum_size < idx->pack->mwf.size) { |
1187
|
0 |
5 |
if (idx->off + (ssize_t)checksum_size > idx->pack->mwf.size) { |
1193
|
0 |
5 |
if (packfile_trailer == NULL) { |
1203
|
0 |
5 |
if (mismatch) { |
1211
|
0 |
5 |
if ((error = resolve_deltas(idx, stats)) < 0) |
1214
|
0 |
5 |
if (stats->indexed_objects != stats->total_objects) { |
1219
|
0 |
5 |
if (stats->local_objects > 0) { |
1220
|
0 |
0 |
if (update_header_and_rehash(idx, stats) < 0) |
1233
|
0 |
5 |
if (git_oidmap_size(idx->expected_oids) > 0) { |
1244
|
0 |
5 |
if (git_hash_fmt(idx->name, checksum, checksum_size) < 0) |
1250
|
0 |
5 |
if (git_str_oom(&filename)) |
1253
|
0 |
5 |
if (git_filebuf_open(&index_file, filename.ptr, |
|
0 |
5 |
if (git_filebuf_open(&index_file, filename.ptr, |
1265
|
1280 |
5 |
for (i = 0; i < 256; ++i) { |
1271
|
45 |
5 |
git_vector_foreach(&idx->objects, i, entry) { |
1276
|
45 |
5 |
git_vector_foreach(&idx->objects, i, entry) { |
1281
|
45 |
5 |
git_vector_foreach(&idx->objects, i, entry) { |
1284
|
0 |
45 |
if (entry->offset == UINT32_MAX) |
1293
|
45 |
5 |
git_vector_foreach(&idx->objects, i, entry) { |
1296
|
45 |
0 |
if (entry->offset != UINT32_MAX) |
1306
|
0 |
5 |
if (git_filebuf_write(&index_file, checksum, checksum_size) < 0) |
1310
|
0 |
5 |
if (git_filebuf_hash(checksum, &index_file) < 0) |
1316
|
0 |
5 |
if (index_path(&filename, idx, ".idx") < 0) |
1320
|
0 |
5 |
if (git_filebuf_commit_at(&index_file, filename.ptr) < 0) |
1323
|
0 |
5 |
if (git_mwindow_free_all(&idx->pack->mwf) < 0) |
1340
|
0 |
5 |
if (idx->do_fsync && p_fsync(idx->pack->mwf.fd) < 0) { |
|
0 |
0 |
if (idx->do_fsync && p_fsync(idx->pack->mwf.fd) < 0) { |
1346
|
0 |
5 |
if (p_close(idx->pack->mwf.fd) < 0) { |
1353
|
0 |
5 |
if (index_path(&filename, idx, ".pack") < 0) |
1357
|
0 |
5 |
if (p_rename(idx->pack->pack_name, git_str_cstr(&filename)) < 0) |
1383
|
0 |
5 |
if (idx == NULL) |
1386
|
0 |
5 |
if (idx->have_stream) |
1391
|
5 |
0 |
if (idx->pack->idx_cache) { |
1393
|
45 |
5 |
git_oidmap_foreach_value(idx->pack->idx_cache, pentry, { |
1405
|
0 |
5 |
while (git_oidmap_iterate((void **) &value, idx->expected_oids, &iter, &key) == 0) |