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

[PATCH 02/11] midx: extern a pair of shared functions

From
Taylor Blau <me@ttaylorr.com>
Date
Mar 25, 2024, 17:24 UTC
Message-ID
<b776fd528d39144780e50750bdc1013e7eb3477a.1711387439.git.me@ttaylorr.com>
In-Reply-To
<cover.1711387439.git.me@ttaylorr.com>

The following commits will incrementally move code specific to writing MIDXs from midx.c to their new home in midx-write.c.

Prepare for that by externing a pair of functions which:
  - will (temporarily) need to be called from both midx.c and
    midx-write.c, but
  - are implementation details that should not be exposed via the midx.h
    header.

Declare these functions as extern within midx-write.c, and introduce a similar (non-extern) declaration within midx.c. This change will be effectively reverted by the end of this series.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 midx-write.c | 10 ++++++++++
 midx.c       | 24 +++++++++++++++++-------
 2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/midx-write.c b/midx-write.c
index 214179d308..4aab273243 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -1,2 +1,12 @@
 #include "git-compat-util.h"
 #include "midx.h"
+
+extern int write_midx_internal(const char *object_dir,
+			       struct string_list *packs_to_include,
+			       struct string_list *packs_to_drop,
+			       const char *preferred_pack_name,
+			       const char *refs_snapshot,
+			       unsigned flags);
+
+extern struct multi_pack_index *lookup_multi_pack_index(struct repository *r,
+							const char *object_dir);
diff --git a/midx.c b/midx.c
index 85e1c2cd12..5f22f01716 100644
--- a/midx.c
+++ b/midx.c
@@ -23,6 +23,16 @@
 #include "list-objects.h"
 #include "pack-revindex.h"
 
+struct multi_pack_index *lookup_multi_pack_index(struct repository *r,
+							const char *object_dir);
+
+int write_midx_internal(const char *object_dir,
+			       struct string_list *packs_to_include,
+			       struct string_list *packs_to_drop,
+			       const char *preferred_pack_name,
+			       const char *refs_snapshot,
+			       unsigned flags);
+
 #define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
 #define MIDX_VERSION 1
 #define MIDX_BYTE_FILE_VERSION 4
@@ -1347,7 +1357,7 @@ static int write_midx_bitmap(const char *midx_name,
 	return ret;
 }
 
-static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,
+struct multi_pack_index *lookup_multi_pack_index(struct repository *r,
 							const char *object_dir)
 {
 	struct multi_pack_index *result = NULL;
@@ -1372,12 +1382,12 @@ static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,
 	return result;
 }
 
-static int write_midx_internal(const char *object_dir,
-			       struct string_list *packs_to_include,
-			       struct string_list *packs_to_drop,
-			       const char *preferred_pack_name,
-			       const char *refs_snapshot,
-			       unsigned flags)
+int write_midx_internal(const char *object_dir,
+			struct string_list *packs_to_include,
+			struct string_list *packs_to_drop,
+			const char *preferred_pack_name,
+			const char *refs_snapshot,
+			unsigned flags)
 {
 	struct strbuf midx_name = STRBUF_INIT;
 	unsigned char midx_hash[GIT_MAX_RAWSZ];
-- 
2.44.0.290.g736be63234b
Previous: Taylor BlauNext: Taylor Blau
Message 5 of 30 in “midx: split MIDX writing routines into midx-write.c, cleanup”
  1. 00/11 midx: split MIDX writing routines into midx-write.c, cleanupTaylor Blau, Mar 25, 2024
  2. 01/11 midx-write: initial commitTaylor Blau, Mar 25, 2024
  3. Junio C HamanoMar 25, 2024
  4. Taylor BlauMar 25, 2024
  5. 02/11 midx: extern a pair of shared functionsTaylor Blau, Mar 25, 2024
  6. 03/11 midx: move `midx_repack` (and related functions) to midx-write.cTaylor Blau, Mar 25, 2024
  7. 04/11 midx: move `expire_midx_packs` to midx-write.cTaylor Blau, Mar 25, 2024
  8. 05/11 midx: move `write_midx_file_only` to midx-write.cTaylor Blau, Mar 25, 2024
  9. 06/11 midx: move `write_midx_file` to midx-write.cTaylor Blau, Mar 25, 2024
  10. 07/11 midx: move `write_midx_internal` (and related functions) to midx-write.cTaylor Blau, Mar 25, 2024
  11. 08/11 midx-write.c: avoid directly managed temporary strbufTaylor Blau, Mar 25, 2024
  12. Junio C HamanoMar 25, 2024
  13. Taylor BlauMar 25, 2024
  14. 09/11 midx-write.c: factor out common want_included_pack() routineTaylor Blau, Mar 25, 2024
  15. Junio C HamanoMar 25, 2024
  16. Jeff KingMar 27, 2024
  17. 10/11 midx-write.c: check count of packs to repack after groupingTaylor Blau, Mar 25, 2024
  18. Junio C HamanoMar 25, 2024
  19. Taylor BlauMar 25, 2024
  20. 11/11 midx-write.c: use `--stdin-packs` when repackingTaylor Blau, Mar 25, 2024
  21. Jeff KingMar 27, 2024
  22. Jeff KingMar 27, 2024
  23. 0/4 midx: split MIDX writing routines into midx-write.c, cleanupTaylor Blau, Apr 1, 2024
  24. 1/4 midx-write: move writing-related functions from midx.cTaylor Blau, Apr 1, 2024
  25. 2/4 midx-write.c: factor out common want_included_pack() routineTaylor Blau, Apr 1, 2024
  26. Patrick SteinhardtApr 2, 2024
  27. 3/4 midx-write.c: check count of packs to repack after groupingTaylor Blau, Apr 1, 2024
  28. 4/4 midx-write.c: use `--stdin-packs` when repackingTaylor Blau, Apr 1, 2024
  29. Junio C HamanoApr 1, 2024
  30. Patrick SteinhardtApr 2, 2024

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.