multi-pack-index: add 'write' verb
authorDerrick Stolee <stolee@gmail.com>
Thu, 12 Jul 2018 19:39:21 +0000 (15:39 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Jul 2018 18:27:28 +0000 (11:27 -0700)
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>
Documentation/git-multi-pack-index.txt
Makefile
builtin/multi-pack-index.c
midx.c [new file with mode: 0644]
midx.h [new file with mode: 0644]
t/t5319-multi-pack-index.sh [new file with mode: 0755]

index 74f6f2a..1f97e79 100644 (file)
@@ -9,7 +9,7 @@ git-multi-pack-index - Write and verify multi-pack-indexes
 SYNOPSIS
 --------
 [verse]
-'git multi-pack-index' [--object-dir=<dir>]
+'git multi-pack-index' [--object-dir=<dir>] <verb>
 
 DESCRIPTION
 -----------
@@ -23,6 +23,26 @@ OPTIONS
        `<dir>/packs/multi-pack-index` for the current MIDX file, and
        `<dir>/packs` for the pack-files to index.
 
+write::
+       When given as the verb, write a new MIDX file to
+       `<dir>/packs/multi-pack-index`.
+
+
+EXAMPLES
+--------
+
+* Write a MIDX file for the packfiles in the current .git folder.
++
+-----------------------------------------------
+$ git multi-pack-index write
+-----------------------------------------------
+
+* Write a MIDX file for the packfiles in an alternate object store.
++
+-----------------------------------------------
+$ git multi-pack-index --object-dir <alt> write
+-----------------------------------------------
+
 
 SEE ALSO
 --------
index 5461087..f5636c7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -890,6 +890,7 @@ LIB_OBJS += merge.o
 LIB_OBJS += merge-blobs.o
 LIB_OBJS += merge-recursive.o
 LIB_OBJS += mergesort.o
+LIB_OBJS += midx.o
 LIB_OBJS += name-hash.o
 LIB_OBJS += notes.o
 LIB_OBJS += notes-cache.o
index 3161dda..6a7aa00 100644 (file)
@@ -2,9 +2,10 @@
 #include "cache.h"
 #include "config.h"
 #include "parse-options.h"
+#include "midx.h"
 
 static char const * const builtin_multi_pack_index_usage[] = {
-       N_("git multi-pack-index [--object-dir=<dir>]"),
+       N_("git multi-pack-index [--object-dir=<dir>] write"),
        NULL
 };
 
@@ -30,5 +31,17 @@ int cmd_multi_pack_index(int argc, const char **argv,
        if (!opts.object_dir)
                opts.object_dir = get_object_directory();
 
-       return 0;
+       if (argc == 0)
+               goto usage;
+
+       if (!strcmp(argv[0], "write")) {
+               if (argc > 1)
+                       goto usage;
+
+               return write_midx_file(opts.object_dir);
+       }
+
+usage:
+       usage_with_options(builtin_multi_pack_index_usage,
+                          builtin_multi_pack_index_options);
 }
diff --git a/midx.c b/midx.c
new file mode 100644 (file)
index 0000000..32468db
--- /dev/null
+++ b/midx.c
@@ -0,0 +1,7 @@
+#include "cache.h"
+#include "midx.h"
+
+int write_midx_file(const char *object_dir)
+{
+       return 0;
+}
diff --git a/midx.h b/midx.h
new file mode 100644 (file)
index 0000000..dbdbe9f
--- /dev/null
+++ b/midx.h
@@ -0,0 +1,6 @@
+#ifndef __MIDX_H__
+#define __MIDX_H__
+
+int write_midx_file(const char *object_dir);
+
+#endif
diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
new file mode 100755 (executable)
index 0000000..ec3ddbe
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+test_description='multi-pack-indexes'
+. ./test-lib.sh
+
+test_expect_success 'write midx with no packs' '
+       git multi-pack-index --object-dir=. write
+'
+
+test_done