Merge branch 'ab/unbundle-progress'
Add progress display to "git bundle unbundle". * ab/unbundle-progress: bundle: show progress on "unbundle" index-pack: add --progress-title option bundle API: change "flags" to be "extra_index_pack_args" bundle API: start writing API documentationmaint
commit
67fc02be54
|
@ -13,7 +13,7 @@ SYNOPSIS
|
||||||
[--version=<version>] <file> <git-rev-list-args>
|
[--version=<version>] <file> <git-rev-list-args>
|
||||||
'git bundle' verify [-q | --quiet] <file>
|
'git bundle' verify [-q | --quiet] <file>
|
||||||
'git bundle' list-heads <file> [<refname>...]
|
'git bundle' list-heads <file> [<refname>...]
|
||||||
'git bundle' unbundle <file> [<refname>...]
|
'git bundle' unbundle [--progress] <file> [<refname>...]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
|
|
|
@ -82,6 +82,12 @@ OPTIONS
|
||||||
--strict::
|
--strict::
|
||||||
Die, if the pack contains broken objects or links.
|
Die, if the pack contains broken objects or links.
|
||||||
|
|
||||||
|
--progress-title::
|
||||||
|
For internal use only.
|
||||||
|
+
|
||||||
|
Set the title of the progress bar. The title is "Receiving objects" by
|
||||||
|
default and "Indexing objects" when `--stdin` is specified.
|
||||||
|
|
||||||
--check-self-contained-and-connected::
|
--check-self-contained-and-connected::
|
||||||
Die if the pack contains broken links. For internal use only.
|
Die if the pack contains broken links. For internal use only.
|
||||||
|
|
||||||
|
|
|
@ -162,10 +162,15 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
|
||||||
struct bundle_header header = BUNDLE_HEADER_INIT;
|
struct bundle_header header = BUNDLE_HEADER_INIT;
|
||||||
int bundle_fd = -1;
|
int bundle_fd = -1;
|
||||||
int ret;
|
int ret;
|
||||||
|
int progress = isatty(2);
|
||||||
|
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
|
OPT_BOOL(0, "progress", &progress,
|
||||||
|
N_("show progress meter")),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
char *bundle_file;
|
char *bundle_file;
|
||||||
|
struct strvec extra_index_pack_args = STRVEC_INIT;
|
||||||
|
|
||||||
argc = parse_options_cmd_bundle(argc, argv, prefix,
|
argc = parse_options_cmd_bundle(argc, argv, prefix,
|
||||||
builtin_bundle_unbundle_usage, options, &bundle_file);
|
builtin_bundle_unbundle_usage, options, &bundle_file);
|
||||||
|
@ -177,7 +182,11 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
|
||||||
}
|
}
|
||||||
if (!startup_info->have_repository)
|
if (!startup_info->have_repository)
|
||||||
die(_("Need a repository to unbundle."));
|
die(_("Need a repository to unbundle."));
|
||||||
ret = !!unbundle(the_repository, &header, bundle_fd, 0) ||
|
if (progress)
|
||||||
|
strvec_pushl(&extra_index_pack_args, "-v", "--progress-title",
|
||||||
|
_("Unbundling objects"), NULL);
|
||||||
|
ret = !!unbundle(the_repository, &header, bundle_fd,
|
||||||
|
&extra_index_pack_args) ||
|
||||||
list_bundle_refs(&header, argc, argv);
|
list_bundle_refs(&header, argc, argv);
|
||||||
bundle_header_release(&header);
|
bundle_header_release(&header);
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
|
@ -122,6 +122,7 @@ static int strict;
|
||||||
static int do_fsck_object;
|
static int do_fsck_object;
|
||||||
static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
|
static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
|
||||||
static int verbose;
|
static int verbose;
|
||||||
|
static const char *progress_title;
|
||||||
static int show_resolving_progress;
|
static int show_resolving_progress;
|
||||||
static int show_stat;
|
static int show_stat;
|
||||||
static int check_self_contained_and_connected;
|
static int check_self_contained_and_connected;
|
||||||
|
@ -1153,6 +1154,7 @@ static void parse_pack_objects(unsigned char *hash)
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
progress = start_progress(
|
progress = start_progress(
|
||||||
|
progress_title ? progress_title :
|
||||||
from_stdin ? _("Receiving objects") : _("Indexing objects"),
|
from_stdin ? _("Receiving objects") : _("Indexing objects"),
|
||||||
nr_objects);
|
nr_objects);
|
||||||
for (i = 0; i < nr_objects; i++) {
|
for (i = 0; i < nr_objects; i++) {
|
||||||
|
@ -1800,6 +1802,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
|
||||||
input_len = sizeof(*hdr);
|
input_len = sizeof(*hdr);
|
||||||
} else if (!strcmp(arg, "-v")) {
|
} else if (!strcmp(arg, "-v")) {
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
|
} else if (!strcmp(arg, "--progress-title")) {
|
||||||
|
if (progress_title || (i+1) >= argc)
|
||||||
|
usage(index_pack_usage);
|
||||||
|
progress_title = argv[++i];
|
||||||
} else if (!strcmp(arg, "--show-resolving-progress")) {
|
} else if (!strcmp(arg, "--show-resolving-progress")) {
|
||||||
show_resolving_progress = 1;
|
show_resolving_progress = 1;
|
||||||
} else if (!strcmp(arg, "--report-end-of-input")) {
|
} else if (!strcmp(arg, "--report-end-of-input")) {
|
||||||
|
|
12
bundle.c
12
bundle.c
|
@ -569,18 +569,18 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
int unbundle(struct repository *r, struct bundle_header *header,
|
int unbundle(struct repository *r, struct bundle_header *header,
|
||||||
int bundle_fd, int flags)
|
int bundle_fd, struct strvec *extra_index_pack_args)
|
||||||
{
|
{
|
||||||
const char *argv_index_pack[] = {"index-pack",
|
|
||||||
"--fix-thin", "--stdin", NULL, NULL};
|
|
||||||
struct child_process ip = CHILD_PROCESS_INIT;
|
struct child_process ip = CHILD_PROCESS_INIT;
|
||||||
|
strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL);
|
||||||
|
|
||||||
if (flags & BUNDLE_VERBOSE)
|
if (extra_index_pack_args) {
|
||||||
argv_index_pack[3] = "-v";
|
strvec_pushv(&ip.args, extra_index_pack_args->v);
|
||||||
|
strvec_clear(extra_index_pack_args);
|
||||||
|
}
|
||||||
|
|
||||||
if (verify_bundle(r, header, 0))
|
if (verify_bundle(r, header, 0))
|
||||||
return -1;
|
return -1;
|
||||||
ip.argv = argv_index_pack;
|
|
||||||
ip.in = bundle_fd;
|
ip.in = bundle_fd;
|
||||||
ip.no_stdout = 1;
|
ip.no_stdout = 1;
|
||||||
ip.git_cmd = 1;
|
ip.git_cmd = 1;
|
||||||
|
|
14
bundle.h
14
bundle.h
|
@ -26,9 +26,19 @@ int create_bundle(struct repository *r, const char *path,
|
||||||
int argc, const char **argv, struct strvec *pack_options,
|
int argc, const char **argv, struct strvec *pack_options,
|
||||||
int version);
|
int version);
|
||||||
int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
|
int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
|
||||||
#define BUNDLE_VERBOSE 1
|
|
||||||
|
/**
|
||||||
|
* Unbundle after reading the header with read_bundle_header().
|
||||||
|
*
|
||||||
|
* We'll invoke "git index-pack --stdin --fix-thin" for you on the
|
||||||
|
* provided `bundle_fd` from read_bundle_header().
|
||||||
|
*
|
||||||
|
* Provide "extra_index_pack_args" to pass any extra arguments
|
||||||
|
* (e.g. "-v" for verbose/progress), NULL otherwise. The provided
|
||||||
|
* "extra_index_pack_args" (if any) will be strvec_clear()'d for you.
|
||||||
|
*/
|
||||||
int unbundle(struct repository *r, struct bundle_header *header,
|
int unbundle(struct repository *r, struct bundle_header *header,
|
||||||
int bundle_fd, int flags);
|
int bundle_fd, struct strvec *extra_index_pack_args);
|
||||||
int list_bundle_refs(struct bundle_header *header,
|
int list_bundle_refs(struct bundle_header *header,
|
||||||
int argc, const char **argv);
|
int argc, const char **argv);
|
||||||
|
|
||||||
|
|
|
@ -162,12 +162,16 @@ static int fetch_refs_from_bundle(struct transport *transport,
|
||||||
int nr_heads, struct ref **to_fetch)
|
int nr_heads, struct ref **to_fetch)
|
||||||
{
|
{
|
||||||
struct bundle_transport_data *data = transport->data;
|
struct bundle_transport_data *data = transport->data;
|
||||||
|
struct strvec extra_index_pack_args = STRVEC_INIT;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (transport->progress)
|
||||||
|
strvec_push(&extra_index_pack_args, "-v");
|
||||||
|
|
||||||
if (!data->get_refs_from_bundle_called)
|
if (!data->get_refs_from_bundle_called)
|
||||||
get_refs_from_bundle(transport, 0, NULL);
|
get_refs_from_bundle(transport, 0, NULL);
|
||||||
ret = unbundle(the_repository, &data->header, data->fd,
|
ret = unbundle(the_repository, &data->header, data->fd,
|
||||||
transport->progress ? BUNDLE_VERBOSE : 0);
|
&extra_index_pack_args);
|
||||||
transport->hash_algo = data->header.hash_algo;
|
transport->hash_algo = data->header.hash_algo;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue