Browse Source
Create a new multi_pack_index struct for loading multi-pack-indexes into memory. Create a test-tool builtin for reading basic information about that multi-pack-index to verify the correct data is written. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
Derrick Stolee
7 years ago
committed by
Junio C Hamano
8 changed files with 143 additions and 1 deletions
@ -1,6 +1,24 @@
@@ -1,6 +1,24 @@
|
||||
#ifndef __MIDX_H__ |
||||
#define __MIDX_H__ |
||||
|
||||
struct multi_pack_index { |
||||
int fd; |
||||
|
||||
const unsigned char *data; |
||||
size_t data_len; |
||||
|
||||
uint32_t signature; |
||||
unsigned char version; |
||||
unsigned char hash_len; |
||||
unsigned char num_chunks; |
||||
uint32_t num_packs; |
||||
uint32_t num_objects; |
||||
|
||||
char object_dir[FLEX_ARRAY]; |
||||
}; |
||||
|
||||
struct multi_pack_index *load_multi_pack_index(const char *object_dir); |
||||
|
||||
int write_midx_file(const char *object_dir); |
||||
|
||||
#endif |
||||
|
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#include "test-tool.h" |
||||
#include "cache.h" |
||||
#include "midx.h" |
||||
#include "repository.h" |
||||
#include "object-store.h" |
||||
|
||||
static int read_midx_file(const char *object_dir) |
||||
{ |
||||
struct multi_pack_index *m = load_multi_pack_index(object_dir); |
||||
|
||||
if (!m) |
||||
return 1; |
||||
|
||||
printf("header: %08x %d %d %d\n", |
||||
m->signature, |
||||
m->version, |
||||
m->num_chunks, |
||||
m->num_packs); |
||||
|
||||
printf("object-dir: %s\n", m->object_dir); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
int cmd__read_midx(int argc, const char **argv) |
||||
{ |
||||
if (argc != 2) |
||||
usage("read-midx <object-dir>"); |
||||
|
||||
return read_midx_file(argv[1]); |
||||
} |
Loading…
Reference in new issue