| line |
true |
false |
branch |
|
56
|
0 |
2 |
if (!e) |
|
69
|
2 |
0 |
if (e != NULL) { |
|
70
|
0 |
2 |
assert(e->refcount.val == 0); |
|
80
|
8 |
0 |
if (cache->entries) { |
|
81
|
2 |
8 |
git_offmap_foreach_value(cache->entries, entry, { |
|
92
|
0 |
9 |
if (git_offmap_new(&cache->entries) < 0) |
|
97
|
0 |
9 |
if (git_mutex_init(&cache->lock)) { |
|
113
|
0 |
5 |
if (git_mutex_lock(&cache->lock) < 0) |
|
116
|
0 |
5 |
if ((entry = git_offmap_get(cache->entries, offset)) != NULL) { |
|
131
|
0 |
0 |
git_offmap_foreach(cache->entries, offset, entry, { |
|
|
0 |
0 |
git_offmap_foreach(cache->entries, offset, entry, { |
|
|
0 |
0 |
git_offmap_foreach(cache->entries, offset, entry, { |
|
149
|
0 |
2 |
if (base->len > GIT_PACK_CACHE_SIZE_LIMIT) |
|
153
|
2 |
0 |
if (entry) { |
|
154
|
0 |
2 |
if (git_mutex_lock(&cache->lock) < 0) { |
|
161
|
2 |
0 |
if (!exists) { |
|
162
|
0 |
2 |
while (cache->memory_used + base->len > cache->memory_limit) |
|
172
|
0 |
2 |
if (exists) { |
|
189
|
0 |
8 |
if (p->oids) { |
|
193
|
3 |
5 |
if (p->index_map.data) { |
|
209
|
0 |
3 |
if (fd < 0) |
|
212
|
0 |
3 |
if (p_fstat(fd, &st) < 0) { |
|
219
|
0 |
3 |
!git__is_sizet(st.st_size) || |
|
231
|
0 |
3 |
if (error < 0) |
|
236
|
3 |
0 |
if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) { |
|
239
|
3 |
0 |
if (version < 2 || version > 2) { |
|
|
0 |
3 |
if (version < 2 || version > 2) { |
|
250
|
3 |
0 |
if (version > 1) |
|
253
|
768 |
3 |
for (i = 0; i < 256; i++) { |
|
255
|
0 |
768 |
if (n < nr) { |
|
262
|
0 |
3 |
if (version == 1) { |
|
270
|
0 |
0 |
if (idx_size != 4*256 + nr * 24 + 20 + 20) { |
|
274
|
3 |
0 |
} else if (version == 2) { |
|
291
|
3 |
0 |
if (nr) |
|
294
|
3 |
0 |
if (idx_size < min_size || idx_size > max_size) { |
|
|
0 |
3 |
if (idx_size < min_size || idx_size > max_size) { |
|
311
|
0 |
3 |
if (p->index_version > -1) |
|
315
|
0 |
3 |
assert(name_len > strlen(".pack")); /* checked by git_pack_file alloc */ |
|
317
|
0 |
3 |
if (git_buf_init(&idx_name, name_len) < 0) |
|
322
|
0 |
3 |
if (git_buf_oom(&idx_name)) { |
|
327
|
0 |
3 |
if ((error = git_mutex_lock(&p->lock)) < 0) { |
|
332
|
3 |
0 |
if (p->index_version == -1) |
|
348
|
0 |
54 |
if (p->mwf.fd == -1 && packfile_open(p) < 0) |
|
|
0 |
0 |
if (p->mwf.fd == -1 && packfile_open(p) < 0) |
|
359
|
2 |
52 |
if (offset > (p->mwf.size - 20)) |
|
361
|
0 |
52 |
if (offset < 0) |
|
380
|
53 |
0 |
assert(type >= GIT_OBJECT_COMMIT && type <= GIT_OBJECT_REF_DELTA); |
|
|
0 |
53 |
assert(type >= GIT_OBJECT_COMMIT && type <= GIT_OBJECT_REF_DELTA); |
|
388
|
45 |
53 |
while (size) { |
|
414
|
43 |
52 |
while (c & 0x80) { |
|
415
|
0 |
43 |
if (len <= used) { |
|
420
|
0 |
43 |
if (bitsizeof(long) <= shift) { |
|
456
|
0 |
52 |
if (base == NULL) |
|
461
|
0 |
52 |
if (ret == GIT_EBUFS) |
|
463
|
0 |
52 |
else if (ret < 0) |
|
484
|
0 |
2 |
if (error < 0) |
|
487
|
2 |
0 |
if (type == GIT_OBJECT_OFS_DELTA || type == GIT_OBJECT_REF_DELTA) { |
|
|
0 |
2 |
if (type == GIT_OBJECT_OFS_DELTA || type == GIT_OBJECT_REF_DELTA) { |
|
494
|
0 |
0 |
if (error < 0) |
|
497
|
0 |
0 |
if ((error = git_packfile_stream_open(&stream, p, curpos)) < 0) |
|
501
|
0 |
0 |
if (error < 0) |
|
508
|
0 |
2 |
while (type == GIT_OBJECT_OFS_DELTA || type == GIT_OBJECT_REF_DELTA) { |
|
|
0 |
2 |
while (type == GIT_OBJECT_OFS_DELTA || type == GIT_OBJECT_REF_DELTA) { |
|
511
|
0 |
0 |
if (error < 0) |
|
513
|
0 |
0 |
if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA) |
|
|
0 |
0 |
if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA) |
|
519
|
0 |
0 |
if (error < 0) |
|
553
|
0 |
5 |
if ((cached = cache_get(&p->bases, obj_offset)) != NULL) { |
|
560
|
0 |
5 |
if (elem_pos == SMALL_STACK_SIZE) { |
|
562
|
0 |
0 |
GIT_ERROR_CHECK_ARRAY(chain); |
|
569
|
5 |
0 |
if (!use_heap) { |
|
572
|
0 |
0 |
elem = git_array_alloc(chain); |
|
|
0 |
0 |
elem = git_array_alloc(chain); |
|
573
|
0 |
0 |
if (!elem) { |
|
583
|
0 |
5 |
if (error < 0) |
|
591
|
5 |
0 |
if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA) |
|
|
3 |
2 |
if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA) |
|
597
|
0 |
2 |
if (error < 0) |
|
638
|
0 |
3 |
if (error < 0) |
|
646
|
0 |
3 |
stack = chain.ptr ? chain.ptr : small_stack; |
|
649
|
0 |
3 |
if (cached) { |
|
663
|
3 |
0 |
if (!cached) { |
|
669
|
0 |
3 |
if (error < 0) |
|
687
|
0 |
3 |
if (cached && stack_size == 1) { |
|
|
0 |
0 |
if (cached && stack_size == 1) { |
|
690
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, obj->len, 1); |
|
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, obj->len, 1); |
|
692
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(obj->data); |
|
700
|
2 |
3 |
while (elem_pos > 0 && !error) { |
|
|
2 |
0 |
while (elem_pos > 0 && !error) { |
|
707
|
2 |
0 |
if (!cached) |
|
715
|
0 |
2 |
if (error < 0) { |
|
737
|
0 |
2 |
if (free_base) { |
|
742
|
2 |
0 |
if (cached) { |
|
747
|
0 |
2 |
if (error < 0) |
|
754
|
0 |
3 |
if (error < 0) { |
|
756
|
0 |
0 |
if (cached) |
|
760
|
3 |
0 |
if (elem) |
|
773
|
0 |
45 |
if (git_zstream_init(&obj->zstream, GIT_ZSTREAM_INFLATE) < 0) { |
|
787
|
45 |
47 |
if (obj->done) |
|
790
|
2 |
45 |
if ((in = pack_window_open(obj->p, &obj->mw, obj->curpos, &window_len)) == NULL) |
|
793
|
45 |
0 |
if ((error = git_zstream_set_input(&obj->zstream, in, window_len)) < 0 || |
|
|
0 |
45 |
if ((error = git_zstream_set_input(&obj->zstream, in, window_len)) < 0 || |
|
804
|
45 |
0 |
if (git_zstream_eos(&obj->zstream)) |
|
808
|
0 |
45 |
if (!len && !git_zstream_eos(&obj->zstream)) |
|
|
0 |
0 |
if (!len && !git_zstream_eos(&obj->zstream)) |
|
833
|
0 |
5 |
GIT_ERROR_CHECK_ALLOC_ADD(&buffer_len, size, 1); |
|
|
0 |
5 |
GIT_ERROR_CHECK_ALLOC_ADD(&buffer_len, size, 1); |
|
835
|
0 |
5 |
GIT_ERROR_CHECK_ALLOC(data); |
|
837
|
0 |
5 |
if ((error = git_zstream_init(&zstream, GIT_ZSTREAM_INFLATE)) < 0) { |
|
849
|
5 |
0 |
if ((error = git_zstream_set_input(&zstream, in, window_len)) < 0 || |
|
|
0 |
5 |
if ((error = git_zstream_set_input(&zstream, in, window_len)) < 0 || |
|
859
|
0 |
5 |
} while (total < size); |
|
861
|
5 |
0 |
if (total != size || !git_zstream_eos(&zstream)) { |
|
|
0 |
5 |
if (total != size || !git_zstream_eos(&zstream)) { |
|
873
|
0 |
5 |
if (error) |
|
896
|
0 |
2 |
assert(delta_base_out); |
|
900
|
0 |
2 |
if (base_info == NULL) |
|
908
|
0 |
2 |
if (type == GIT_OBJECT_OFS_DELTA) { |
|
912
|
0 |
0 |
while (c & 128) { |
|
913
|
0 |
0 |
if (left <= used) |
|
916
|
0 |
0 |
if (!unsigned_base_offset || MSB(unsigned_base_offset, 7)) |
|
|
0 |
0 |
if (!unsigned_base_offset || MSB(unsigned_base_offset, 7)) |
|
921
|
0 |
0 |
if (unsigned_base_offset == 0 || (size_t)delta_obj_offset <= unsigned_base_offset) |
|
|
0 |
0 |
if (unsigned_base_offset == 0 || (size_t)delta_obj_offset <= unsigned_base_offset) |
|
925
|
2 |
0 |
} else if (type == GIT_OBJECT_REF_DELTA) { |
|
927
|
2 |
0 |
if (p->has_cache) { |
|
932
|
2 |
0 |
if ((entry = git_oidmap_get(p->idx_cache, &oid)) != NULL) { |
|
933
|
0 |
2 |
if (entry->offset == 0) |
|
949
|
0 |
0 |
if (pack_entry_find_offset(&base_offset, &unused, p, (git_oid *)base_info, GIT_OID_HEXSZ) < 0) |
|
955
|
0 |
0 |
if (base_offset == 0) |
|
970
|
3 |
5 |
if (p->mwf.fd >= 0) { |
|
976
|
0 |
8 |
if (unlink_packfile) |
|
982
|
0 |
8 |
if (!p) |
|
1005
|
0 |
3 |
if (p->index_version == -1 && pack_index_open(p) < 0) |
|
|
0 |
0 |
if (p->index_version == -1 && pack_index_open(p) < 0) |
|
1009
|
0 |
3 |
if (git_mutex_lock(&p->lock) < 0) |
|
1012
|
0 |
3 |
if (p->mwf.fd >= 0) { |
|
1019
|
0 |
3 |
if (p->mwf.fd < 0) |
|
1027
|
0 |
3 |
if (!p->mwf.size) { |
|
1028
|
0 |
0 |
if (!S_ISREG(st.st_mode)) |
|
1031
|
0 |
3 |
} else if (p->mwf.size != st.st_size) |
|
1049
|
0 |
3 |
hdr.hdr_signature != htonl(PACK_SIGNATURE) || |
|
1050
|
0 |
0 |
!pack_version_ok(hdr.hdr_version)) |
|
1055
|
3 |
0 |
p_lseek(p->mwf.fd, p->mwf.size - GIT_OID_RAWSZ, SEEK_SET) == -1 || |
|
1061
|
0 |
3 |
if (git_oid__cmp(&sha1, (git_oid *)idx_sha1) != 0) |
|
1070
|
0 |
0 |
if (p->mwf.fd >= 0) |
|
1086
|
0 |
4 |
if (path_len < strlen(".idx")) |
|
1089
|
0 |
4 |
if (git_buf_printf(&buf, "%.*s.pack", (int)(path_len - strlen(".idx")), path) < 0) |
|
1100
|
9 |
0 |
size_t path_len = path ? strlen(path) : 0, alloc_len; |
|
1104
|
0 |
9 |
if (path_len < strlen(".idx")) |
|
1107
|
0 |
9 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*p), path_len); |
|
|
0 |
9 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*p), path_len); |
|
1108
|
0 |
9 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); |
|
|
0 |
9 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); |
|
1111
|
0 |
9 |
GIT_ERROR_CHECK_ALLOC(p); |
|
1119
|
3 |
6 |
if (git__suffixcmp(path, ".idx") == 0) { |
|
1122
|
3 |
0 |
if (!git_disable_pack_keep_file_checks) { |
|
1124
|
0 |
3 |
if (git_path_exists(p->pack_name) == true) |
|
1131
|
9 |
0 |
if (p_stat(p->pack_name, &st) < 0 || !S_ISREG(st.st_mode)) { |
|
|
0 |
9 |
if (p_stat(p->pack_name, &st) < 0 || !S_ISREG(st.st_mode)) { |
|
1145
|
0 |
9 |
if (git_mutex_init(&p->lock)) { |
|
1151
|
0 |
9 |
if (cache_init(&p->bases) < 0) { |
|
1172
|
0 |
3 |
if (p->index_version == 1) { |
|
1178
|
3 |
0 |
if (!(off & 0x80000000)) |
|
1183
|
0 |
0 |
if (index >= end - 8) |
|
1204
|
0 |
0 |
if (index == NULL) { |
|
1205
|
0 |
0 |
if ((error = pack_index_open(p)) < 0) |
|
1208
|
0 |
0 |
assert(p->index_map.data); |
|
1213
|
0 |
0 |
if (p->index_version > 1) { |
|
1219
|
0 |
0 |
if (p->oids == NULL) { |
|
1222
|
0 |
0 |
if ((error = git_vector_init(&oids, p->num_objects, NULL))) |
|
1225
|
0 |
0 |
if ((error = git_vector_init(&offsets, p->num_objects, git__memcmp4))) |
|
1228
|
0 |
0 |
if (p->index_version > 1) { |
|
1230
|
0 |
0 |
for (i = 0; i < p->num_objects; i++) |
|
1233
|
0 |
0 |
git_vector_foreach(&offsets, i, current) |
|
1236
|
0 |
0 |
for (i = 0; i < p->num_objects; i++) |
|
1239
|
0 |
0 |
git_vector_foreach(&offsets, i, current) |
|
1247
|
0 |
0 |
for (i = 0; i < p->num_objects; i++) |
|
1248
|
0 |
0 |
if ((error = cb(p->oids[i], data)) != 0) |
|
1259
|
3 |
0 |
while (lo < hi) { |
|
1263
|
3 |
0 |
if (!cmp) |
|
1266
|
0 |
0 |
if (cmp > 0) |
|
1291
|
3 |
0 |
if (p->index_version == -1) { |
|
1294
|
0 |
3 |
if ((error = pack_index_open(p)) < 0) |
|
1296
|
0 |
3 |
assert(p->index_map.data); |
|
1302
|
3 |
0 |
if (p->index_version > 1) { |
|
1309
|
3 |
0 |
lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(level1_ofs[(int)short_oid->id[0] - 1])); |
|
1311
|
3 |
0 |
if (p->index_version > 1) { |
|
1325
|
3 |
0 |
if (pos >= 0) { |
|
1333
|
0 |
0 |
if (pos < (int)p->num_objects) { |
|
1336
|
0 |
0 |
if (!git_oid_ncmp(short_oid, (const git_oid *)current, len)) |
|
1341
|
3 |
0 |
if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)p->num_objects) { |
|
|
0 |
3 |
if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)p->num_objects) { |
|
|
0 |
0 |
if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)p->num_objects) { |
|
1345
|
0 |
0 |
if (!git_oid_ncmp(short_oid, (const git_oid *)next, len)) { |
|
1350
|
0 |
3 |
if (!found) |
|
1352
|
0 |
3 |
if (found > 1) |
|
1355
|
0 |
3 |
if ((offset = nth_packed_object_offset(p, pos)) < 0) { |
|
1385
|
0 |
3 |
assert(p); |
|
1387
|
3 |
0 |
if (len == GIT_OID_HEXSZ && p->num_bad_objects) { |
|
|
0 |
3 |
if (len == GIT_OID_HEXSZ && p->num_bad_objects) { |
|
1389
|
0 |
0 |
for (i = 0; i < p->num_bad_objects; i++) |
|
1390
|
0 |
0 |
if (git_oid__cmp(short_oid, &p->bad_object_sha1[i]) == 0) |
|
1395
|
0 |
3 |
if (error < 0) |
|
1401
|
3 |
0 |
if (p->mwf.fd == -1 && (error = packfile_open(p)) < 0) |
|
|
0 |
3 |
if (p->mwf.fd == -1 && (error = packfile_open(p)) < 0) |