fix unimplemented packed_object_info_detail() features

Since commit eb32d236df, 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>
This commit is contained in:
Nicolas Pitre 2008-02-28 00:25:19 -05:00 committed by Junio C Hamano
parent 340814636d
commit 70f5d5d31c
2 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,6 @@
#include "cache.h" #include "cache.h"
#include "pack.h" #include "pack.h"
#include "pack-revindex.h"
struct idx_entry struct idx_entry
{ {
@ -101,8 +102,10 @@ static int verify_packfile(struct packed_git *p,
static void show_pack_info(struct packed_git *p) static void show_pack_info(struct packed_git *p)
{ {
uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1]; uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
nr_objects = p->num_objects; nr_objects = p->num_objects;
memset(chain_histogram, 0, sizeof(chain_histogram)); memset(chain_histogram, 0, sizeof(chain_histogram));
init_pack_revindex();
for (i = 0; i < nr_objects; i++) { for (i = 0; i < nr_objects; i++) {
const unsigned char *sha1; const unsigned char *sha1;

View File

@ -14,6 +14,7 @@
#include "tag.h" #include "tag.h"
#include "tree.h" #include "tree.h"
#include "refs.h" #include "refs.h"
#include "pack-revindex.h"
#ifndef O_NOATIME #ifndef O_NOATIME
#if defined(__linux__) && (defined(__i386__) || defined(__PPC__)) #if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@ -1367,11 +1368,15 @@ const char *packed_object_info_detail(struct packed_git *p,
unsigned long dummy; unsigned long dummy;
unsigned char *next_sha1; unsigned char *next_sha1;
enum object_type type; enum object_type type;
struct revindex_entry *revidx;
*delta_chain_length = 0; *delta_chain_length = 0;
curpos = obj_offset; curpos = obj_offset;
type = unpack_object_header(p, &w_curs, &curpos, size); type = unpack_object_header(p, &w_curs, &curpos, size);
revidx = find_pack_revindex(p, obj_offset);
*store_size = revidx[1].offset - obj_offset;
for (;;) { for (;;) {
switch (type) { switch (type) {
default: default:
@ -1381,14 +1386,13 @@ const char *packed_object_info_detail(struct packed_git *p,
case OBJ_TREE: case OBJ_TREE:
case OBJ_BLOB: case OBJ_BLOB:
case OBJ_TAG: case OBJ_TAG:
*store_size = 0; /* notyet */
unuse_pack(&w_curs); unuse_pack(&w_curs);
return typename(type); return typename(type);
case OBJ_OFS_DELTA: case OBJ_OFS_DELTA:
obj_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset); obj_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset);
if (*delta_chain_length == 0) { if (*delta_chain_length == 0) {
/* TODO: find base_sha1 as pointed by curpos */ revidx = find_pack_revindex(p, obj_offset);
hashclr(base_sha1); hashcpy(base_sha1, nth_packed_object_sha1(p, revidx->nr));
} }
break; break;
case OBJ_REF_DELTA: case OBJ_REF_DELTA: