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

[PATCH 00/17] Refactor chunk-format into an API

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 26, 2021, 16:01 UTC
Message-ID
<pull.848.git.1611676886.gitgitgadget@gmail.com>

This is a restart on the topic previously submitted [1] but dropped because ak/corrected-commit-date was still in progress. This version is based on that branch.

[1] https://lore.kernel.org/git/pull.804.git.1607012215.gitgitgadget@gmail.com/

This version also changes the approach to use a more dynamic interaction with a struct chunkfile pointer. This idea is credited to Taylor Blau [2], but I started again from scratch. I also go further to make struct chunkfile anonymous to API consumers. It is defined only in chunk-format.c, which should hopefully deter future users from interacting with that data directly.

[2] https://lore.kernel.org/git/X8%2FI%2FRzXZksio+ri@nand.local/

This combined API is beneficial to reduce duplicated logic. Or rather, to ensure that similar file formats have similar protections against bad data. The multi-pack-index code did not have as many guards as the commit-graph code did, but now they both share a common base that checks for things like duplicate chunks or offsets outside the size of the file.

Here are some stats for the end-to-end change:
 * 638 insertions(+), 456 deletions(-).
 * commit-graph.c: 171 insertions(+), 192 deletions(-)
 * midx.c: 196 insertions(+), 260 deletions(-)

While there is an overall increase to the code size, the consumers do get a bit smaller. Boilerplate things like abstracting method to match chunk_write_fn and chunk_read_fn make up a lot of these insertions. The "interesting" code gets a lot smaller and cleaner.

Thanks, -Stolee
Derrick Stolee (17):
  commit-graph: anonymize data in chunk_write_fn
  chunk-format: create chunk format write API
  commit-graph: use chunk-format write API
  midx: rename pack_info to write_midx_context
  midx: use context in write_midx_pack_names()
  midx: add entries to write_midx_context
  midx: add pack_perm to write_midx_context
  midx: add num_large_offsets to write_midx_context
  midx: return success/failure in chunk write methods
  midx: drop chunk progress during write
  midx: use chunk-format API in write_midx_internal()
  chunk-format: create read chunk API
  commit-graph: use chunk-format read API
  midx: use chunk-format read API
  midx: use 64-bit multiplication for chunk sizes
  chunk-format: restore duplicate chunk checks
  chunk-format: add technical docs
 Documentation/technical/chunk-format.txt      |  54 +++
 .../technical/commit-graph-format.txt         |   3 +
 Documentation/technical/pack-format.txt       |   3 +
 Makefile                                      |   1 +
 chunk-format.c                                | 165 +++++++
 chunk-format.h                                |  41 ++
 commit-graph.c                                | 363 +++++++-------
 midx.c                                        | 456 ++++++++----------
 t/t5318-commit-graph.sh                       |   2 +-
 t/t5319-multi-pack-index.sh                   |   6 +-
 10 files changed, 638 insertions(+), 456 deletions(-)
 create mode 100644 Documentation/technical/chunk-format.txt
 create mode 100644 chunk-format.c
 create mode 100644 chunk-format.h
base-commit: 5a3b130cad0d5c770f766e3af6d32b41766374c0
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-848%2Fderrickstolee%2Fchunk-format%2Frefactor-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-848/derrickstolee/chunk-format/refactor-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/848
-- 
gitgitgadget
Next: Derrick Stolee via GitGitGadget
Message 1 of 120 in “Refactor chunk-format into an API”
  1. 00/17 Refactor chunk-format into an APIDerrick Stolee via GitGitGadget, Jan 26, 2021
  2. 02/17 chunk-format: create chunk format write APIDerrick Stolee via GitGitGadget, Jan 26, 2021
  3. Taylor BlauJan 27, 2021
  4. Derrick StoleeJan 27, 2021
  5. 01/17 commit-graph: anonymize data in chunk_write_fnDerrick Stolee via GitGitGadget, Jan 26, 2021
  6. Chris TorekJan 27, 2021
  7. Taylor BlauJan 27, 2021
  8. 05/17 midx: use context in write_midx_pack_names()Derrick Stolee via GitGitGadget, Jan 26, 2021
  9. 06/17 midx: add entries to write_midx_contextDerrick Stolee via GitGitGadget, Jan 26, 2021
  10. 04/17 midx: rename pack_info to write_midx_contextDerrick Stolee via GitGitGadget, Jan 26, 2021
  11. Taylor BlauJan 27, 2021
  12. 03/17 commit-graph: use chunk-format write APIDerrick Stolee via GitGitGadget, Jan 26, 2021
  13. Taylor BlauJan 27, 2021
  14. 14/17 midx: use chunk-format read APIDerrick Stolee via GitGitGadget, Jan 26, 2021
  15. Taylor BlauJan 27, 2021
  16. Derrick StoleeJan 27, 2021
  17. 17/17 chunk-format: add technical docsDerrick Stolee via GitGitGadget, Jan 26, 2021
  18. 11/17 midx: use chunk-format API in write_midx_internal()Derrick Stolee via GitGitGadget, Jan 26, 2021
  19. 16/17 chunk-format: restore duplicate chunk checksDerrick Stolee via GitGitGadget, Jan 26, 2021
  20. 15/17 midx: use 64-bit multiplication for chunk sizesDerrick Stolee via GitGitGadget, Jan 26, 2021
  21. 07/17 midx: add pack_perm to write_midx_contextDerrick Stolee via GitGitGadget, Jan 26, 2021
  22. 10/17 midx: drop chunk progress during writeDerrick Stolee via GitGitGadget, Jan 26, 2021
  23. 09/17 midx: return success/failure in chunk write methodsDerrick Stolee via GitGitGadget, Jan 26, 2021
  24. 08/17 midx: add num_large_offsets to write_midx_contextDerrick Stolee via GitGitGadget, Jan 26, 2021
  25. 13/17 commit-graph: use chunk-format read APIDerrick Stolee via GitGitGadget, Jan 26, 2021
  26. 12/17 chunk-format: create read chunk APIDerrick Stolee via GitGitGadget, Jan 26, 2021
  27. Taylor BlauJan 27, 2021
  28. Taylor BlauJan 27, 2021
  29. Junio C HamanoJan 26, 2021
  30. 00/17 Refactor chunk-format into an APIDerrick Stolee via GitGitGadget, Jan 27, 2021
  31. 05/17 midx: use context in write_midx_pack_names()Derrick Stolee via GitGitGadget, Jan 27, 2021
  32. 03/17 commit-graph: use chunk-format write APIDerrick Stolee via GitGitGadget, Jan 27, 2021
  33. 07/17 midx: add pack_perm to write_midx_contextDerrick Stolee via GitGitGadget, Jan 27, 2021
  34. 02/17 chunk-format: create chunk format write APIDerrick Stolee via GitGitGadget, Jan 27, 2021
  35. Junio C HamanoFeb 4, 2021
  36. Junio C HamanoFeb 4, 2021
  37. Derrick StoleeFeb 5, 2021
  38. Junio C HamanoFeb 5, 2021
  39. 15/17 midx: use 64-bit multiplication for chunk sizesDerrick Stolee via GitGitGadget, Jan 27, 2021
  40. Junio C HamanoFeb 5, 2021
  41. Chris TorekFeb 5, 2021
  42. Junio C HamanoFeb 5, 2021
  43. Chris TorekFeb 6, 2021
  44. Derrick StoleeFeb 5, 2021
  45. Junio C HamanoFeb 5, 2021
  46. SZEDER GáborFeb 7, 2021
  47. Junio C HamanoFeb 8, 2021
  48. 17/17 chunk-format: add technical docsDerrick Stolee via GitGitGadget, Jan 27, 2021
  49. Junio C HamanoFeb 5, 2021
  50. 14/17 midx: use chunk-format read APIDerrick Stolee via GitGitGadget, Jan 27, 2021
  51. 13/17 commit-graph: use chunk-format read APIDerrick Stolee via GitGitGadget, Jan 27, 2021
  52. 16/17 chunk-format: restore duplicate chunk checksDerrick Stolee via GitGitGadget, Jan 27, 2021
  53. Junio C HamanoFeb 5, 2021
  54. Derrick StoleeFeb 5, 2021
  55. 11/17 midx: use chunk-format API in write_midx_internal()Derrick Stolee via GitGitGadget, Jan 27, 2021
  56. 12/17 chunk-format: create read chunk APIDerrick Stolee via GitGitGadget, Jan 27, 2021
  57. Junio C HamanoFeb 4, 2021
  58. Derrick StoleeFeb 5, 2021
  59. Junio C HamanoFeb 5, 2021
  60. Junio C HamanoFeb 8, 2021
  61. Derrick StoleeFeb 9, 2021
  62. Junio C HamanoFeb 9, 2021
  63. 09/17 midx: return success/failure in chunk write methodsDerrick Stolee via GitGitGadget, Jan 27, 2021
  64. Junio C HamanoFeb 4, 2021
  65. Derrick StoleeFeb 5, 2021
  66. 10/17 midx: drop chunk progress during writeDerrick Stolee via GitGitGadget, Jan 27, 2021
  67. 06/17 midx: add entries to write_midx_contextDerrick Stolee via GitGitGadget, Jan 27, 2021
  68. 08/17 midx: add num_large_offsets to write_midx_contextDerrick Stolee via GitGitGadget, Jan 27, 2021
  69. 04/17 midx: rename pack_info to write_midx_contextDerrick Stolee via GitGitGadget, Jan 27, 2021
  70. 01/17 commit-graph: anonymize data in chunk_write_fnDerrick Stolee via GitGitGadget, Jan 27, 2021
  71. Taylor BlauJan 27, 2021
  72. Junio C HamanoFeb 5, 2021
  73. Derrick StoleeFeb 5, 2021
  74. 00/17 Refactor chunk-format into an APIDerrick Stolee via GitGitGadget, Feb 5, 2021
  75. 10/17 midx: drop chunk progress during writeDerrick Stolee via GitGitGadget, Feb 5, 2021
  76. 17/17 chunk-format: add technical docsDerrick Stolee via GitGitGadget, Feb 5, 2021
  77. 09/17 midx: return success/failure in chunk write methodsDerrick Stolee via GitGitGadget, Feb 5, 2021
  78. 15/17 midx: use 64-bit multiplication for chunk sizesDerrick Stolee via GitGitGadget, Feb 5, 2021
  79. 02/17 chunk-format: create chunk format write APIDerrick Stolee via GitGitGadget, Feb 5, 2021
  80. SZEDER GáborFeb 7, 2021
  81. Derrick StoleeFeb 8, 2021
  82. SZEDER GáborFeb 11, 2021
  83. 08/17 midx: add num_large_offsets to write_midx_contextDerrick Stolee via GitGitGadget, Feb 5, 2021
  84. 05/17 midx: use context in write_midx_pack_names()Derrick Stolee via GitGitGadget, Feb 5, 2021
  85. 14/17 midx: use chunk-format read APIDerrick Stolee via GitGitGadget, Feb 5, 2021
  86. 07/17 midx: add pack_perm to write_midx_contextDerrick Stolee via GitGitGadget, Feb 5, 2021
  87. 06/17 midx: add entries to write_midx_contextDerrick Stolee via GitGitGadget, Feb 5, 2021
  88. 16/17 chunk-format: restore duplicate chunk checksDerrick Stolee via GitGitGadget, Feb 5, 2021
  89. 13/17 commit-graph: use chunk-format read APIDerrick Stolee via GitGitGadget, Feb 5, 2021
  90. 01/17 commit-graph: anonymize data in chunk_write_fnDerrick Stolee via GitGitGadget, Feb 5, 2021
  91. 03/17 commit-graph: use chunk-format write APIDerrick Stolee via GitGitGadget, Feb 5, 2021
  92. 04/17 midx: rename pack_info to write_midx_contextDerrick Stolee via GitGitGadget, Feb 5, 2021
  93. 11/17 midx: use chunk-format API in write_midx_internal()Derrick Stolee via GitGitGadget, Feb 5, 2021
  94. 12/17 chunk-format: create read chunk APIDerrick Stolee via GitGitGadget, Feb 5, 2021
  95. SZEDER GáborFeb 7, 2021
  96. Derrick StoleeFeb 8, 2021
  97. 00/17 Refactor chunk-format into an APIDerrick Stolee via GitGitGadget, Feb 18, 2021
  98. 07/17 midx: add pack_perm to write_midx_contextDerrick Stolee via GitGitGadget, Feb 18, 2021
  99. 05/17 midx: use context in write_midx_pack_names()Derrick Stolee via GitGitGadget, Feb 18, 2021
  100. 03/17 commit-graph: use chunk-format write APIDerrick Stolee via GitGitGadget, Feb 18, 2021
  101. SZEDER GáborFeb 24, 2021
  102. Taylor BlauFeb 24, 2021
  103. Derrick StoleeFeb 24, 2021
  104. Junio C HamanoFeb 24, 2021
  105. 04/17 midx: rename pack_info to write_midx_contextDerrick Stolee via GitGitGadget, Feb 18, 2021
  106. 06/17 midx: add entries to write_midx_contextDerrick Stolee via GitGitGadget, Feb 18, 2021
  107. 02/17 chunk-format: create chunk format write APIDerrick Stolee via GitGitGadget, Feb 18, 2021
  108. 01/17 commit-graph: anonymize data in chunk_write_fnDerrick Stolee via GitGitGadget, Feb 18, 2021
  109. 08/17 midx: add num_large_offsets to write_midx_contextDerrick Stolee via GitGitGadget, Feb 18, 2021
  110. 09/17 midx: return success/failure in chunk write methodsDerrick Stolee via GitGitGadget, Feb 18, 2021
  111. 10/17 midx: drop chunk progress during writeDerrick Stolee via GitGitGadget, Feb 18, 2021
  112. 11/17 midx: use chunk-format API in write_midx_internal()Derrick Stolee via GitGitGadget, Feb 18, 2021
  113. 12/17 chunk-format: create read chunk APIDerrick Stolee via GitGitGadget, Feb 18, 2021
  114. 17/17 chunk-format: add technical docsDerrick Stolee via GitGitGadget, Feb 18, 2021
  115. Junio C HamanoFeb 18, 2021
  116. Derrick StoleeFeb 19, 2021
  117. 15/17 midx: use 64-bit multiplication for chunk sizesDerrick Stolee via GitGitGadget, Feb 18, 2021
  118. 14/17 midx: use chunk-format read APIDerrick Stolee via GitGitGadget, Feb 18, 2021
  119. 13/17 commit-graph: use chunk-format read APIDerrick Stolee via GitGitGadget, Feb 18, 2021
  120. 16/17 chunk-format: restore duplicate chunk checksDerrick Stolee via GitGitGadget, Feb 18, 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.