multi-pack-index: add 'verify' verb
The multi-pack-index builtin writes multi-pack-index files, and uses a 'write' verb to do so. Add a 'verify' verb that checks this file matches the contents of the pack-indexes it replaces. The current implementation is a no-op, but will be extended in small increments in later commits. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6a22d52126
commit
56ee7ff156
@ -27,6 +27,10 @@ write::
|
||||
When given as the verb, write a new MIDX file to
|
||||
`<dir>/packs/multi-pack-index`.
|
||||
|
||||
verify::
|
||||
When given as the verb, verify the contents of the MIDX file
|
||||
at `<dir>/packs/multi-pack-index`.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
@ -43,6 +47,12 @@ $ git multi-pack-index write
|
||||
$ git multi-pack-index --object-dir <alt> write
|
||||
-----------------------------------------------
|
||||
|
||||
* Verify the MIDX file for the packfiles in the current .git folder.
|
||||
+
|
||||
-----------------------------------------------
|
||||
$ git multi-pack-index verify
|
||||
-----------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "midx.h"
|
||||
|
||||
static char const * const builtin_multi_pack_index_usage[] = {
|
||||
N_("git multi-pack-index [--object-dir=<dir>] write"),
|
||||
N_("git multi-pack-index [--object-dir=<dir>] (write|verify)"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -42,6 +42,8 @@ int cmd_multi_pack_index(int argc, const char **argv,
|
||||
|
||||
if (!strcmp(argv[0], "write"))
|
||||
return write_midx_file(opts.object_dir);
|
||||
if (!strcmp(argv[0], "verify"))
|
||||
return verify_midx_file(opts.object_dir);
|
||||
|
||||
die(_("unrecognized verb: %s"), argv[0]);
|
||||
}
|
||||
|
13
midx.c
13
midx.c
@ -928,3 +928,16 @@ void clear_midx_file(const char *object_dir)
|
||||
|
||||
free(midx);
|
||||
}
|
||||
|
||||
static int verify_midx_error;
|
||||
|
||||
int verify_midx_file(const char *object_dir)
|
||||
{
|
||||
struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
|
||||
verify_midx_error = 0;
|
||||
|
||||
if (!m)
|
||||
return 0;
|
||||
|
||||
return verify_midx_error;
|
||||
}
|
||||
|
1
midx.h
1
midx.h
@ -43,5 +43,6 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
|
||||
|
||||
int write_midx_file(const char *object_dir);
|
||||
void clear_midx_file(const char *object_dir);
|
||||
int verify_midx_file(const char *object_dir);
|
||||
|
||||
#endif
|
||||
|
@ -150,6 +150,10 @@ test_expect_success 'write midx with twelve packs' '
|
||||
|
||||
compare_results_with_midx "twelve packs"
|
||||
|
||||
test_expect_success 'verify multi-pack-index success' '
|
||||
git multi-pack-index verify --object-dir=$objdir
|
||||
'
|
||||
|
||||
test_expect_success 'repack removes multi-pack-index' '
|
||||
test_path_is_file $objdir/pack/multi-pack-index &&
|
||||
git repack -adf &&
|
||||
@ -214,4 +218,8 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
|
||||
midx_read_expect 1 63 5 objects64 " large-offsets"
|
||||
'
|
||||
|
||||
test_expect_success 'verify multi-pack-index with 64-bit offsets' '
|
||||
git multi-pack-index verify --object-dir=objects64
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user