{"thread":{"id":"28425","subject":"[PATCH] Teach progress eye-candy to fetch_refs_from_bundle()","startedAt":"2011-09-18T23:52:32Z","lastAt":"2011-09-18T23:52:32Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"175762","messageId":"7vmxe1be7z.fsf@alter.siamese.dyndns.org","threadId":"28425","inReplyTo":null,"subject":"[PATCH] Teach progress eye-candy to fetch_refs_from_bundle()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-18T23:52:32Z","receivedAt":"2011-09-18T23:52:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"With the usual \"git\" transport, a large-ish transfer with \"git fetch\" and\n\"git pull\" give progress eye-candy to avoid boring users.  However, not\nwhen they are reading from a bundle. I.e.\n\n    $ git pull ../git-bundle.bndl master\n\nThis teaches bundle.c:unbundle() to give \"-v\" option to index-pack and\ntell it to give progress bar when transport decides it is necessary.\n\nThe operation in the other direction, \"git bundle create\", could also\nlearn to honor --quiet but that is a separate issue.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/bundle.c |    2 +-\n bundle.c         |    7 +++++--\n bundle.h         |    3 ++-\n transport.c      |    3 ++-\n 4 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/bundle.c b/builtin/bundle.c\nindex 81046a9..92a8a60 100644\n--- a/builtin/bundle.c\n+++ b/builtin/bundle.c\n@@ -58,7 +58,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)\n \t} else if (!strcmp(cmd, \"unbundle\")) {\n \t\tif (!startup_info->have_repository)\n \t\t\tdie(_(\"Need a repository to unbundle.\"));\n-\t\treturn !!unbundle(&header, bundle_fd) ||\n+\t\treturn !!unbundle(&header, bundle_fd, 0) ||\n \t\t\tlist_bundle_refs(&header, argc, argv);\n \t} else\n \t\tusage(builtin_bundle_usage);\ndiff --git a/bundle.c b/bundle.c\nindex f48fd7d..6bf8497 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -380,12 +380,15 @@ int create_bundle(struct bundle_header *header, const char *path,\n \treturn 0;\n }\n \n-int unbundle(struct bundle_header *header, int bundle_fd)\n+int unbundle(struct bundle_header *header, int bundle_fd, int flags)\n {\n \tconst char *argv_index_pack[] = {\"index-pack\",\n-\t\t\"--fix-thin\", \"--stdin\", NULL};\n+\t\t\t\t\t \"--fix-thin\", \"--stdin\", NULL, NULL};\n \tstruct child_process ip;\n \n+\tif (flags & BUNDLE_VERBOSE)\n+\t\targv_index_pack[3] = \"-v\";\n+\n \tif (verify_bundle(header, 0))\n \t\treturn -1;\n \tmemset(&ip, 0, sizeof(ip));\ndiff --git a/bundle.h b/bundle.h\nindex e2aedd6..c5a22c8 100644\n--- a/bundle.h\n+++ b/bundle.h\n@@ -18,7 +18,8 @@ int read_bundle_header(const char *path, struct bundle_header *header);\n int create_bundle(struct bundle_header *header, const char *path,\n \t\tint argc, const char **argv);\n int verify_bundle(struct bundle_header *header, int verbose);\n-int unbundle(struct bundle_header *header, int bundle_fd);\n+#define BUNDLE_VERBOSE 1\n+int unbundle(struct bundle_header *header, int bundle_fd, int flags);\n int list_bundle_refs(struct bundle_header *header,\n \t\tint argc, const char **argv);\n \ndiff --git a/transport.c b/transport.c\nindex fa279d5..e194061 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -432,7 +432,8 @@ static int fetch_refs_from_bundle(struct transport *transport,\n \t\t\t       int nr_heads, struct ref **to_fetch)\n {\n \tstruct bundle_transport_data *data = transport->data;\n-\treturn unbundle(&data->header, data->fd);\n+\treturn unbundle(&data->header, data->fd,\n+\t\t\ttransport->progress ? BUNDLE_VERBOSE : 0);\n }\n \n static int close_bundle(struct transport *transport)\n"}]}