1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-07 19:46:08 +02:00

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>
This commit is contained in:
Derrick Stolee 2018-07-12 15:39:21 -04:00 committed by Junio C Hamano
parent 6a257f03ba
commit a340773026
6 changed files with 60 additions and 3 deletions

View 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
--------

View File

@ -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

View 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);
}

7
midx.c Normal file
View File

@ -0,0 +1,7 @@
#include "cache.h"
#include "midx.h"
int write_midx_file(const char *object_dir)
{
return 0;
}

6
midx.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef __MIDX_H__
#define __MIDX_H__
int write_midx_file(const char *object_dir);
#endif

10
t/t5319-multi-pack-index.sh Executable file
View File

@ -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