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>
Derrick Stolee committed
Sep 13, 2018 at 11:02 UTC
56ee7ff15655fa1c9a1368ddd717fc84556359bc
5 files changed
+35
-1
Documentation/git-multi-pack-index.txt
+10
@@ -27,6 +27,10 @@ write::
27
When given as the verb, write a new MIDX file to
28
`<dir>/packs/multi-pack-index`.
29
30
+verify::
31
+ When given as the verb, verify the contents of the MIDX file
32
+ at `<dir>/packs/multi-pack-index`.
33
+
34
35
EXAMPLES
36
--------
@@ -43,6 +47,12 @@ $ git multi-pack-index write
47
$ git multi-pack-index --object-dir <alt> write
48
-----------------------------------------------
49
50
+* Verify the MIDX file for the packfiles in the current .git folder.
51
++
52
+-----------------------------------------------
53
+$ git multi-pack-index verify
54
+-----------------------------------------------
55
+
56
57
SEE ALSO
58
--------
builtin/multi-pack-index.c
+3
-1
@@ -5,7 +5,7 @@
5
#include "midx.h"
6
7
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)"),
9
NULL
10
};
11
@@ -42,6 +42,8 @@ int cmd_multi_pack_index(int argc, const char **argv,
42
43
if (!strcmp(argv[0], "write"))
44
return write_midx_file(opts.object_dir);
45
+ if (!strcmp(argv[0], "verify"))
46
+ return verify_midx_file(opts.object_dir);
47
48
die(_("unrecognized verb: %s"), argv[0]);
49
}
midx.c
+13
@@ -928,3 +928,16 @@ void clear_midx_file(const char *object_dir)
928
929
free(midx);
930
}
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
+1
@@ -43,5 +43,6 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
43
44
int write_midx_file(const char *object_dir);
45
void clear_midx_file(const char *object_dir);
46
+int verify_midx_file(const char *object_dir);
47
48
#endif
t/t5319-multi-pack-index.sh
+8
@@ -150,6 +150,10 @@ test_expect_success 'write midx with twelve packs' '
150
151
compare_results_with_midx "twelve packs"
152
153
+test_expect_success 'verify multi-pack-index success' '
154
+ git multi-pack-index verify --object-dir=$objdir
155
+'
156
+
157
test_expect_success 'repack removes multi-pack-index' '
158
test_path_is_file $objdir/pack/multi-pack-index &&
159
git repack -adf &&
@@ -214,4 +218,8 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
218
midx_read_expect 1 63 5 objects64 " large-offsets"
219
'
220
221
+test_expect_success 'verify multi-pack-index with 64-bit offsets' '
222
+ git multi-pack-index verify --object-dir=objects64
223
+'
224
+
225
test_done