git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 4/5] index-pack: add --progress-title option

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 26, 2021, 14:05 UTC
Message-ID
<patch-v3-4.5-e44d825e5df-20210826T140414Z-avarab@gmail.com>
In-Reply-To
<cover-v3-0.5-00000000000-20210826T140414Z-avarab@gmail.com>

Add a --progress-title option to index-pack, when data is piped into index-pack its progress is a proxy for whatever's feeding it data.

This option will allow us to set a more relevant progress bar title in "git bundle unbundle", and is also used in my "bundle-uri" RFC patches[1] by a new caller in fetch-pack.c.

The code change in cmd_index_pack() won't handle "--progress-title=xyz", only "--progress-title xyz", and the "(i+1)" style (as opposed to "i + 1") is a bit odd.

Not using the "--long-option=value" style is inconsistent with existing long options handled by cmd_index_pack(), but makes the code that needs to call it better (two strvec_push(), instead of needing a strvec_pushf()).

Since the option is internal-only the inconsistency shouldn't matter. I'm copying the pattern to handle it as-is from the handling of the existing "-o" option in the same function, see 9cf6d3357aa (Add git-index-pack utility, 2005-10-12) for its addition.

Eventually we'd like to migrate all of this this to parse_options(), which would make these differences in behavior go away.

1. https://lore.kernel.org/git/RFC-cover-00.13-0000000000-20210805T150534Z-avarab@gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/git-index-pack.txt | 6 ++++++
 builtin/index-pack.c             | 6 ++++++
 2 files changed, 12 insertions(+)
diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt
index 7fa74b9e798..1f1e3592251 100644
--- a/Documentation/git-index-pack.txt
+++ b/Documentation/git-index-pack.txt
@@ -82,6 +82,12 @@ OPTIONS
 --strict::
 	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::
 	Die if the pack contains broken links. For internal use only.
 
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 8336466865c..0841c039ae2 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -122,6 +122,7 @@ static int strict;
 static int do_fsck_object;
 static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
 static int verbose;
+static const char *progress_title;
 static int show_resolving_progress;
 static int show_stat;
 static int check_self_contained_and_connected;
@@ -1157,6 +1158,7 @@ static void parse_pack_objects(unsigned char *hash)
 
 	if (verbose)
 		progress = start_progress(
+				progress_title ? progress_title :
 				from_stdin ? _("Receiving objects") : _("Indexing objects"),
 				nr_objects);
 	for (i = 0; i < nr_objects; i++) {
@@ -1806,6 +1808,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 				input_len = sizeof(*hdr);
 			} else if (!strcmp(arg, "-v")) {
 				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")) {
 				show_resolving_progress = 1;
 			} else if (!strcmp(arg, "--report-end-of-input")) {
-- 
2.33.0.733.ga72a4f1c2e1
Previous: Jeff KingNext: Junio C Hamano
Message 33 of 42 in “bundle: show progress on "unbundle"”
  1. 0/4 bundle: show progress on "unbundle"Ævar Arnfjörð Bjarmason, Jul 27, 2021
  2. 2/4 bundle API: change "flags" to be "extra_index_pack_args"Ævar Arnfjörð Bjarmason, Jul 27, 2021
  3. 1/4 bundle API: start writing API documentationÆvar Arnfjörð Bjarmason, Jul 27, 2021
  4. 3/4 index-pack: add --progress-title optionÆvar Arnfjörð Bjarmason, Jul 27, 2021
  5. 4/4 bundle: show progress on "unbundle"Ævar Arnfjörð Bjarmason, Jul 27, 2021
  6. 0/4 bundle: show progress on "unbundle"Ævar Arnfjörð Bjarmason, Aug 23, 2021
  7. 2/4 bundle API: change "flags" to be "extra_index_pack_args"Ævar Arnfjörð Bjarmason, Aug 23, 2021
  8. Derrick StoleeAug 24, 2021
  9. Ævar Arnfjörð BjarmasonAug 24, 2021
  10. Derrick StoleeAug 24, 2021
  11. 1/4 bundle API: start writing API documentationÆvar Arnfjörð Bjarmason, Aug 23, 2021
  12. Derrick StoleeAug 24, 2021
  13. Ævar Arnfjörð BjarmasonAug 24, 2021
  14. 3/4 index-pack: add --progress-title optionÆvar Arnfjörð Bjarmason, Aug 23, 2021
  15. Derrick StoleeAug 24, 2021
  16. Ævar Arnfjörð BjarmasonAug 24, 2021
  17. 4/4 bundle: show progress on "unbundle"Ævar Arnfjörð Bjarmason, Aug 23, 2021
  18. Derrick StoleeAug 24, 2021
  19. Ævar Arnfjörð BjarmasonAug 24, 2021
  20. 0/5 bundle: show progress on "unbundle"Ævar Arnfjörð Bjarmason, Aug 26, 2021
  21. 1/5 bundle API: start writing API documentationÆvar Arnfjörð Bjarmason, Aug 26, 2021
  22. 3/5 bundle API: change "flags" to be "extra_index_pack_args"Ævar Arnfjörð Bjarmason, Aug 26, 2021
  23. Junio C HamanoAug 28, 2021
  24. 2/5 strvec: add a strvec_pushvec()Ævar Arnfjörð Bjarmason, Aug 26, 2021
  25. Junio C HamanoAug 28, 2021
  26. Junio C HamanoAug 28, 2021
  27. Jeff KingAug 28, 2021
  28. Junio C HamanoAug 29, 2021
  29. Derrick StoleeAug 30, 2021
  30. Ævar Arnfjörð BjarmasonSep 2, 2021
  31. Junio C HamanoSep 3, 2021
  32. Jeff KingSep 3, 2021
  33. 4/5 index-pack: add --progress-title optionÆvar Arnfjörð Bjarmason, Aug 26, 2021
  34. Junio C HamanoAug 28, 2021
  35. 5/5 bundle: show progress on "unbundle"Ævar Arnfjörð Bjarmason, Aug 26, 2021
  36. Junio C HamanoAug 28, 2021
  37. Ævar Arnfjörð BjarmasonSep 2, 2021
  38. 0/4 bundle: show progress on "unbundle"Ævar Arnfjörð Bjarmason, Sep 5, 2021
  39. 1/4 bundle API: start writing API documentationÆvar Arnfjörð Bjarmason, Sep 5, 2021
  40. 2/4 bundle API: change "flags" to be "extra_index_pack_args"Ævar Arnfjörð Bjarmason, Sep 5, 2021
  41. 3/4 index-pack: add --progress-title optionÆvar Arnfjörð Bjarmason, Sep 5, 2021
  42. 4/4 bundle: show progress on "unbundle"Ævar Arnfjörð Bjarmason, Sep 5, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.