multi-pack-index: add 'write' verb
In anticipation of writing multi-pack-indexes, add a skeleton 'git multi-pack-index write' subcommand and send the options to a write_midx_file() method. Also create a skeleton test script that tests the 'write' subcommand. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jul 12, 2018 at 15:39 UTC
a3407730261b11b45dda131464b73ec29922392a
6 files changed
+60
-3
Documentation/git-multi-pack-index.txt
+21
-1
@@ -9,7 +9,7 @@ git-multi-pack-index - Write and verify multi-pack-indexes
9
SYNOPSIS
10
--------
11
[verse]
12
-'git multi-pack-index' [--object-dir=<dir>]
12
+'git multi-pack-index' [--object-dir=<dir>] <verb>
13
14
DESCRIPTION
15
-----------
@@ -23,6 +23,26 @@ OPTIONS
23
`<dir>/packs/multi-pack-index` for the current MIDX file, and
24
`<dir>/packs` for the pack-files to index.
25
26
+write::
27
+ When given as the verb, write a new MIDX file to
28
+ `<dir>/packs/multi-pack-index`.
29
+
30
+
31
+EXAMPLES
32
+--------
33
+
34
+* Write a MIDX file for the packfiles in the current .git folder.
35
++
36
+-----------------------------------------------
37
+$ git multi-pack-index write
38
+-----------------------------------------------
39
+
40
+* Write a MIDX file for the packfiles in an alternate object store.
41
++
42
+-----------------------------------------------
43
+$ git multi-pack-index --object-dir <alt> write
44
+-----------------------------------------------
45
+
46
47
SEE ALSO
48
--------
Makefile
+1
@@ -890,6 +890,7 @@ LIB_OBJS += merge.o
890
LIB_OBJS += merge-blobs.o
891
LIB_OBJS += merge-recursive.o
892
LIB_OBJS += mergesort.o
893
+LIB_OBJS += midx.o
894
LIB_OBJS += name-hash.o
895
LIB_OBJS += notes.o
896
LIB_OBJS += notes-cache.o
builtin/multi-pack-index.c
+15
-2
@@ -2,9 +2,10 @@
2
#include "cache.h"
3
#include "config.h"
4
#include "parse-options.h"
5
+#include "midx.h"
6
7
static char const * const builtin_multi_pack_index_usage[] = {
7
- N_("git multi-pack-index [--object-dir=<dir>]"),
8
+ N_("git multi-pack-index [--object-dir=<dir>] write"),
9
NULL
10
};
11
@@ -30,5 +31,17 @@ int cmd_multi_pack_index(int argc, const char **argv,
31
if (!opts.object_dir)
32
opts.object_dir = get_object_directory();
33
33
- return 0;
34
+ if (argc == 0)
35
+ goto usage;
36
+
37
+ if (!strcmp(argv[0], "write")) {
38
+ if (argc > 1)
39
+ goto usage;
40
+
41
+ return write_midx_file(opts.object_dir);
42
+ }
43
+
44
+usage:
45
+ usage_with_options(builtin_multi_pack_index_usage,
46
+ builtin_multi_pack_index_options);
47
}
midx.c
new
+7
@@ -0,0 +1,7 @@
1
+#include "cache.h"
2
+#include "midx.h"
3
+
4
+int write_midx_file(const char *object_dir)
5
+{
6
+ return 0;
7
+}
midx.h
new
+6
@@ -0,0 +1,6 @@
1
+#ifndef __MIDX_H__
2
+#define __MIDX_H__
3
+
4
+int write_midx_file(const char *object_dir);
5
+
6
+#endif
t/t5319-multi-pack-index.sh
new
+10
@@ -0,0 +1,10 @@
1
+#!/bin/sh
2
+
3
+test_description='multi-pack-indexes'
4
+. ./test-lib.sh
5
+
6
+test_expect_success 'write midx with no packs' '
7
+ git multi-pack-index --object-dir=. write
8
+'
9
+
10
+test_done