bundle: show progress on "unbundle"

The "unbundle" command added in 2e0afafebd8 (Add git-bundle: move objects and references by archive, 2007-02-22) did not show progress output, even though the underlying API learned how to show progress in be042aff24c (Teach progress eye-candy to fetch_refs_from_bundle(), 2011-09-18). Now we'll show "Unbundling objects" using the new --progress-title option to "git index-pack", to go with its existing "Receiving objects" and "Indexing objects" (which it shows when invoked with "--stdin", and with a pack file, respectively). Unlike "git bundle create" we don't handle "--quiet" here, nor "--all-progress" and "--all-progress-implied". Those are all specific to "create" (and "verify", in the case of "--quiet"). The structure of the existing documentation is a bit unclear, e.g. the documentation for the "--quiet" option added in 79862b6b77c (bundle-create: progress output control, 2019-11-10) only describes how it works for "create", and not for "verify". That and other issues in it should be fixed, but I'd like to avoid untangling that mess right now. Let's just support the standard "--no-progress" implicitly here, and leave cleaning up the general behavior of "git bundle" for a later change. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Sep 5, 2021 at 09:34 UTC d941cc4c342f4feca6be2a410ac6dc56908880ec
2 files changed +8 -1
Documentation/git-bundle.txt
+1 -1
@@ -13,7 +13,7 @@ SYNOPSIS
13 [--version=<version>] <file> <git-rev-list-args>
14 'git bundle' verify [-q | --quiet] <file>
15 'git bundle' list-heads <file> [<refname>...]
16 -'git bundle' unbundle <file> [<refname>...]
16 +'git bundle' unbundle [--progress] <file> [<refname>...]
17
18 DESCRIPTION
19 -----------
builtin/bundle.c
+7
@@ -162,7 +162,11 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
162 struct bundle_header header = BUNDLE_HEADER_INIT;
163 int bundle_fd = -1;
164 int ret;
165 + int progress = isatty(2);
166 +
167 struct option options[] = {
168 + OPT_BOOL(0, "progress", &progress,
169 + N_("show progress meter")),
170 OPT_END()
171 };
172 char *bundle_file;
@@ -178,6 +182,9 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
182 }
183 if (!startup_info->have_repository)
184 die(_("Need a repository to unbundle."));
185 + if (progress)
186 + strvec_pushl(&extra_index_pack_args, "-v", "--progress-title",
187 + _("Unbundling objects"), NULL);
188 ret = !!unbundle(the_repository, &header, bundle_fd,
189 &extra_index_pack_args) ||
190 list_bundle_refs(&header, argc, argv);