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

[PATCH v4 2/6] midx: add progress to write_midx_file

From
WGWilliam Baker via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 21, 2019, 18:39 UTC
Message-ID
<37768f58860d113e21730f2640ca773ebb54dff0.1571683203.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.337.v4.git.1571683203.gitgitgadget@gmail.com>
From: William Baker <William.Baker@microsoft.com>

Add progress to write_midx_file. Progress is displayed when the MIDX_PROGRESS flag is set.

Signed-off-by: William Baker <William.Baker@microsoft.com>
---
 midx.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/midx.c b/midx.c
index f169a681dd..006f36b570 100644
--- a/midx.c
+++ b/midx.c
@@ -448,6 +448,8 @@ struct pack_list {
 	uint32_t nr;
 	uint32_t alloc;
 	struct multi_pack_index *m;
+	struct progress *progress;
+	unsigned pack_paths_checked;
 };
 
 static void add_pack_to_midx(const char *full_path, size_t full_path_len,
@@ -456,6 +458,7 @@ static void add_pack_to_midx(const char *full_path, size_t full_path_len,
 	struct pack_list *packs = (struct pack_list *)data;
 
 	if (ends_with(file_name, ".idx")) {
+		display_progress(packs->progress, ++packs->pack_paths_checked);
 		if (packs->m && midx_contains_pack(packs->m, file_name))
 			return;
 
@@ -785,7 +788,7 @@ static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_off
 }
 
 static int write_midx_internal(const char *object_dir, struct multi_pack_index *m,
-			       struct string_list *packs_to_drop)
+			       struct string_list *packs_to_drop, unsigned flags)
 {
 	unsigned char cur_chunk, num_chunks = 0;
 	char *midx_name;
@@ -799,6 +802,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
 	uint64_t chunk_offsets[MIDX_MAX_CHUNKS + 1];
 	uint32_t nr_entries, num_large_offsets = 0;
 	struct pack_midx_entry *entries = NULL;
+	struct progress *progress = NULL;
 	int large_offsets_needed = 0;
 	int pack_name_concat_len = 0;
 	int dropped_packs = 0;
@@ -832,8 +836,15 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
 			packs.nr++;
 		}
 	}
+	
+	packs.pack_paths_checked = 0;
+	if (flags & MIDX_PROGRESS)
+		packs.progress = start_progress(_("Adding packfiles to multi-pack-index"), 0);
+	else
+		packs.progress = NULL;
 
 	for_each_file_in_pack_dir(object_dir, add_pack_to_midx, &packs);
+	stop_progress(&packs.progress);
 
 	if (packs.m && packs.nr == packs.m->num_packs && !packs_to_drop)
 		goto cleanup;
@@ -958,6 +969,9 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
 		written += MIDX_CHUNKLOOKUP_WIDTH;
 	}
 
+	if (flags & MIDX_PROGRESS)
+		progress = start_progress(_("Writing chunks to multi-pack-index"),
+					  num_chunks);
 	for (i = 0; i < num_chunks; i++) {
 		if (written != chunk_offsets[i])
 			BUG("incorrect chunk offset (%"PRIu64" != %"PRIu64") for chunk id %"PRIx32,
@@ -990,7 +1004,10 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
 				BUG("trying to write unknown chunk id %"PRIx32,
 				    chunk_ids[i]);
 		}
+
+		display_progress(progress, i + 1);
 	}
+	stop_progress(&progress);
 
 	if (written != chunk_offsets[num_chunks])
 		BUG("incorrect final offset %"PRIu64" != %"PRIu64,
@@ -1018,7 +1035,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
 
 int write_midx_file(const char *object_dir, unsigned flags)
 {
-	return write_midx_internal(object_dir, NULL, NULL);
+	return write_midx_internal(object_dir, NULL, NULL, flags);
 }
 
 void clear_midx_file(struct repository *r)
@@ -1221,7 +1238,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
 	free(count);
 
 	if (packs_to_drop.nr)
-		result = write_midx_internal(object_dir, m, &packs_to_drop);
+		result = write_midx_internal(object_dir, m, &packs_to_drop, flags);
 
 	string_list_clear(&packs_to_drop, 0);
 	return result;
@@ -1370,7 +1387,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
 		goto cleanup;
 	}
 
-	result = write_midx_internal(object_dir, m, NULL);
+	result = write_midx_internal(object_dir, m, NULL, flags);
 	m = NULL;
 
 cleanup:
-- 
gitgitgadget
Previous: William Baker via GitGitGadget
Message 58 of 58 in “multi-pack-index: add --no-progress”
  1. 0/1 multi-pack-index: add --no-progressWilliam Baker via GitGitGadget, Sep 11, 2019
  2. 1/1 multi-pack-index: add --no-progress Add --no-progress option to git multi-pack-index. The progress feature was added in 144d703 ("multi-pack-index: report progress during 'verify'", 2018-09-13) but the ability to opt-out was overlooked.William Baker via GitGitGadget, Sep 11, 2019
  3. Junio C HamanoSep 12, 2019
  4. William BakerSep 13, 2019
  5. Junio C HamanoSep 13, 2019
  6. William BakerSep 16, 2019
  7. Derrick StoleeSep 11, 2019
  8. 0/6 multi-pack-index: add --no-progressWilliam Baker via GitGitGadget, Sep 20, 2019
  9. 1/6 midx: add MIDX_PROGRESS flag Add the MIDX_PROGRESS flag and update the write|verify|expire|repack functions in midx.h to accept a flags parameter. The MIDX_PROGRESS flag indicates whether the caller of the function would like progress information to be displayed. This patch only changes the method prototypes and does not change the functionality. The functionality change will be handled by a later patch.William Baker via GitGitGadget, Sep 20, 2019
  10. Junio C HamanoSep 20, 2019
  11. Junio C HamanoSep 20, 2019
  12. SZEDER GáborSep 21, 2019
  13. William BakerSep 23, 2019
  14. Junio C HamanoSep 28, 2019
  15. William BakerSep 30, 2019
  16. Junio C HamanoOct 2, 2019
  17. Junio C HamanoOct 2, 2019
  18. Junio C HamanoOct 2, 2019
  19. William BakerOct 2, 2019
  20. SZEDER GáborOct 7, 2019
  21. SZEDER GáborOct 7, 2019
  22. Junio C HamanoOct 8, 2019
  23. William BakerOct 8, 2019
  24. SZEDER GáborOct 9, 2019
  25. SZEDER GáborOct 9, 2019
  26. William BakerOct 15, 2019
  27. Junio C HamanoOct 16, 2019
  28. William BakerOct 16, 2019
  29. William BakerOct 18, 2019
  30. 5/6 midx: honor the MIDX_PROGRESS flag in midx_repack Update midx_repack to only display progress when the MIDX_PROGRESS flag is set.William Baker via GitGitGadget, Sep 20, 2019
  31. Junio C HamanoSep 20, 2019
  32. 4/6 midx: honor the MIDX_PROGRESS flag in verify_midx_file Update verify_midx_file to only display progress when the MIDX_PROGRESS flag is set.William Baker via GitGitGadget, Sep 20, 2019
  33. 2/6 midx: add progress to write_midx_file Add progress to write_midx_file. Progress is displayed when the MIDX_PROGRESS flag is set.William Baker via GitGitGadget, Sep 20, 2019
  34. Junio C HamanoSep 20, 2019
  35. William BakerSep 23, 2019
  36. Junio C HamanoSep 28, 2019
  37. William BakerSep 30, 2019
  38. 3/6 midx: add progress to expire_midx_packs Add progress to expire_midx_packs. Progress is displayed when the MIDX_PROGRESS flag is set.William Baker via GitGitGadget, Sep 20, 2019
  39. 6/6 multi-pack-index: add [--[no-]progress] option. Add the --[no-]progress option to git multi-pack-index. Pass the MIDX_PROGRESS flag to the subcommand functions when progress should be displayed by multi-pack-index. The progress feature was added to 'verify' in 144d703 ("multi-pack-index: report progress during 'verify'", 2018-09-13) but some subcommands were not updated to display progress, and the ability to opt-out was overlooked.William Baker via GitGitGadget, Sep 20, 2019
  40. Junio C HamanoSep 20, 2019
  41. William BakerSep 20, 2019
  42. Philip OakleySep 20, 2019
  43. William BakerSep 20, 2019
  44. 0/6 multi-pack-index: add --no-progressWilliam Baker via GitGitGadget, Oct 3, 2019
  45. 1/6 midx: add MIDX_PROGRESS flagWilliam Baker via GitGitGadget, Oct 3, 2019
  46. 3/6 midx: add progress to expire_midx_packsWilliam Baker via GitGitGadget, Oct 3, 2019
  47. 2/6 midx: add progress to write_midx_fileWilliam Baker via GitGitGadget, Oct 3, 2019
  48. 5/6 midx: honor the MIDX_PROGRESS flag in midx_repackWilliam Baker via GitGitGadget, Oct 3, 2019
  49. 4/6 midx: honor the MIDX_PROGRESS flag in verify_midx_fileWilliam Baker via GitGitGadget, Oct 3, 2019
  50. 6/6 multi-pack-index: add [--[no-]progress] option.William Baker via GitGitGadget, Oct 3, 2019
  51. Junio C HamanoOct 3, 2019
  52. 0/6 multi-pack-index: add --no-progressWilliam Baker via GitGitGadget, Oct 21, 2019
  53. 3/6 midx: add progress to expire_midx_packsWilliam Baker via GitGitGadget, Oct 21, 2019
  54. 1/6 midx: add MIDX_PROGRESS flagWilliam Baker via GitGitGadget, Oct 21, 2019
  55. 5/6 midx: honor the MIDX_PROGRESS flag in midx_repackWilliam Baker via GitGitGadget, Oct 21, 2019
  56. 4/6 midx: honor the MIDX_PROGRESS flag in verify_midx_fileWilliam Baker via GitGitGadget, Oct 21, 2019
  57. 6/6 multi-pack-index: add [--[no-]progress] option.William Baker via GitGitGadget, Oct 21, 2019
  58. 2/6 midx: add progress to write_midx_fileWilliam Baker via GitGitGadget, Oct 21, 2019

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.