Skip to content

Commit 56ee7ff

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a22d52 commit 56ee7ff

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

Documentation/git-multi-pack-index.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ write::
2727
When given as the verb, write a new MIDX file to
2828
`<dir>/packs/multi-pack-index`.
2929

30+
verify::
31+
When given as the verb, verify the contents of the MIDX file
32+
at `<dir>/packs/multi-pack-index`.
33+
3034

3135
EXAMPLES
3236
--------
@@ -43,6 +47,12 @@ $ git multi-pack-index write
4347
$ git multi-pack-index --object-dir <alt> write
4448
-----------------------------------------------
4549

50+
* Verify the MIDX file for the packfiles in the current .git folder.
51+
+
52+
-----------------------------------------------
53+
$ git multi-pack-index verify
54+
-----------------------------------------------
55+
4656

4757
SEE ALSO
4858
--------

builtin/multi-pack-index.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "midx.h"
66

77
static char const * const builtin_multi_pack_index_usage[] = {
8-
N_("git multi-pack-index [--object-dir=<dir>] write"),
8+
N_("git multi-pack-index [--object-dir=<dir>] (write|verify)"),
99
NULL
1010
};
1111

@@ -42,6 +42,8 @@ int cmd_multi_pack_index(int argc, const char **argv,
4242

4343
if (!strcmp(argv[0], "write"))
4444
return write_midx_file(opts.object_dir);
45+
if (!strcmp(argv[0], "verify"))
46+
return verify_midx_file(opts.object_dir);
4547

4648
die(_("unrecognized verb: %s"), argv[0]);
4749
}

midx.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,3 +928,16 @@ void clear_midx_file(const char *object_dir)
928928

929929
free(midx);
930930
}
931+
932+
static int verify_midx_error;
933+
934+
int verify_midx_file(const char *object_dir)
935+
{
936+
struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
937+
verify_midx_error = 0;
938+
939+
if (!m)
940+
return 0;
941+
942+
return verify_midx_error;
943+
}

midx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
4343

4444
int write_midx_file(const char *object_dir);
4545
void clear_midx_file(const char *object_dir);
46+
int verify_midx_file(const char *object_dir);
4647

4748
#endif

t/t5319-multi-pack-index.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ test_expect_success 'write midx with twelve packs' '
150150

151151
compare_results_with_midx "twelve packs"
152152

153+
test_expect_success 'verify multi-pack-index success' '
154+
git multi-pack-index verify --object-dir=$objdir
155+
'
156+
153157
test_expect_success 'repack removes multi-pack-index' '
154158
test_path_is_file $objdir/pack/multi-pack-index &&
155159
git repack -adf &&
@@ -214,4 +218,8 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
214218
midx_read_expect 1 63 5 objects64 " large-offsets"
215219
'
216220

221+
test_expect_success 'verify multi-pack-index with 64-bit offsets' '
222+
git multi-pack-index verify --object-dir=objects64
223+
'
224+
217225
test_done

0 commit comments

Comments
 (0)