Teach progress eye-candy to fetch_refs_from_bundle()

With the usual "git" transport, a large-ish transfer with "git fetch" and "git pull" give progress eye-candy to avoid boring users. However, not when they are reading from a bundle. I.e. $ git pull ../git-bundle.bndl master This teaches bundle.c:unbundle() to give "-v" option to index-pack and tell it to give progress bar when transport decides it is necessary. The operation in the other direction, "git bundle create", could also learn to honor --quiet but that is a separate issue. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 18, 2011 at 16:52 UTC be042aff24c8a17565934874f5d2eebd77ab2562
4 files changed +10 -5
builtin/bundle.c
+1 -1
@@ -58,7 +58,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
58 } else if (!strcmp(cmd, "unbundle")) {
59 if (!startup_info->have_repository)
60 die(_("Need a repository to unbundle."));
61 - return !!unbundle(&header, bundle_fd) ||
61 + return !!unbundle(&header, bundle_fd, 0) ||
62 list_bundle_refs(&header, argc, argv);
63 } else
64 usage(builtin_bundle_usage);
bundle.c
+5 -2
@@ -380,12 +380,15 @@ int create_bundle(struct bundle_header *header, const char *path,
380 return 0;
381 }
382
383 -int unbundle(struct bundle_header *header, int bundle_fd)
383 +int unbundle(struct bundle_header *header, int bundle_fd, int flags)
384 {
385 const char *argv_index_pack[] = {"index-pack",
386 - "--fix-thin", "--stdin", NULL};
386 + "--fix-thin", "--stdin", NULL, NULL};
387 struct child_process ip;
388
389 + if (flags & BUNDLE_VERBOSE)
390 + argv_index_pack[3] = "-v";
391 +
392 if (verify_bundle(header, 0))
393 return -1;
394 memset(&ip, 0, sizeof(ip));
bundle.h
+2 -1
@@ -18,7 +18,8 @@ int read_bundle_header(const char *path, struct bundle_header *header);
18 int create_bundle(struct bundle_header *header, const char *path,
19 int argc, const char **argv);
20 int verify_bundle(struct bundle_header *header, int verbose);
21 -int unbundle(struct bundle_header *header, int bundle_fd);
21 +#define BUNDLE_VERBOSE 1
22 +int unbundle(struct bundle_header *header, int bundle_fd, int flags);
23 int list_bundle_refs(struct bundle_header *header,
24 int argc, const char **argv);
25
transport.c
+2 -1
@@ -431,7 +431,8 @@ static int fetch_refs_from_bundle(struct transport *transport,
431 int nr_heads, struct ref **to_fetch)
432 {
433 struct bundle_transport_data *data = transport->data;
434 - return unbundle(&data->header, data->fd);
434 + return unbundle(&data->header, data->fd,
435 + transport->progress ? BUNDLE_VERBOSE : 0);
436 }
437
438 static int close_bundle(struct transport *transport)