@matheusbsbs / matheus-bagliano / commits / 70f5d5d31c
Fork 0

fix unimplemented packed_object_info_detail() features

Since commit eb32d236df0c16b936b04f0c5402addb61cdb311, there was a TODO comment in packed_object_info_detail() about the SHA1 of base object to OBJ_OFS_DELTA objects. So here it is at last. While at it, providing the actual storage size information as well is now trivial. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed Feb 28, 2008 at 00:25 UTC 70f5d5d31cbf0ba273083805124ad67135142527
2 files changed +10 -3
pack-check.c
+3
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "pack.h"
3 +#include "pack-revindex.h"
4
5 struct idx_entry
6 {
@@ -101,8 +102,10 @@ static int verify_packfile(struct packed_git *p,
102 static void show_pack_info(struct packed_git *p)
103 {
104 uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
105 +
106 nr_objects = p->num_objects;
107 memset(chain_histogram, 0, sizeof(chain_histogram));
108 + init_pack_revindex();
109
110 for (i = 0; i < nr_objects; i++) {
111 const unsigned char *sha1;
sha1_file.c
+7 -3
@@ -14,6 +14,7 @@
14 #include "tag.h"
15 #include "tree.h"
16 #include "refs.h"
17 +#include "pack-revindex.h"
18
19 #ifndef O_NOATIME
20 #if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@@ -1367,11 +1368,15 @@ const char *packed_object_info_detail(struct packed_git *p,
1368 unsigned long dummy;
1369 unsigned char *next_sha1;
1370 enum object_type type;
1371 + struct revindex_entry *revidx;
1372
1373 *delta_chain_length = 0;
1374 curpos = obj_offset;
1375 type = unpack_object_header(p, &w_curs, &curpos, size);
1376
1377 + revidx = find_pack_revindex(p, obj_offset);
1378 + *store_size = revidx[1].offset - obj_offset;
1379 +
1380 for (;;) {
1381 switch (type) {
1382 default:
@@ -1381,14 +1386,13 @@ const char *packed_object_info_detail(struct packed_git *p,
1386 case OBJ_TREE:
1387 case OBJ_BLOB:
1388 case OBJ_TAG:
1384 - *store_size = 0; /* notyet */
1389 unuse_pack(&w_curs);
1390 return typename(type);
1391 case OBJ_OFS_DELTA:
1392 obj_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset);
1393 if (*delta_chain_length == 0) {
1390 - /* TODO: find base_sha1 as pointed by curpos */
1391 - hashclr(base_sha1);
1394 + revidx = find_pack_revindex(p, obj_offset);
1395 + hashcpy(base_sha1, nth_packed_object_sha1(p, revidx->nr));
1396 }
1397 break;
1398 case OBJ_REF_DELTA: