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

[PATCH 2/2] Documentation/gitformat-pack.txt: fix incorrect MIDX documentation

From
Taylor Blau <me@ttaylorr.com>
Date
Oct 12, 2023, 21:09 UTC
Message-ID
<af2742e05dff48c4ba0a9f36d58bcbfc052dca40.1697144959.git.me@ttaylorr.com>
In-Reply-To
<cover.1697144959.git.me@ttaylorr.com>

Back in 32f3c541e3 (multi-pack-index: write pack names in chunk, 2018-07-12) the MIDX's "Packfile Names" (or "PNAM", for short) chunk was described as containing an array of string entries. e0d1bcf825 notes that this is the only chunk in the MIDX format's specification that is not guaranteed to be 4-byte aligned, and so should be placed last.

This isn't quite accurate: the entries within the PNAM chunk are not guaranteed to be aligned since they are arbitrary strings, but the chunk itself is aligned since the ending is padded with NUL bytes.

That external padding has always been there since 32f3c541e3 via midx.c::write_midx_pack_names(), which ended with:

    i = MIDX_CHUNK_ALIGNMENT - (written % MIDX_CHUNK_ALIGNMENT)
    if (i < MIDX_CHUNK_ALIGNMENT) {
      unsigned char padding[MIDX_CHUNK_ALIGNMENT];
      memset(padding, 0, sizeof(padding))
      hashwrite(f, padding, i);
      written += i;
    }

In fact, 32f3c541e3's log message itself describes the chunk in its first paragraph with:

    Since filenames are not well structured, add padding to keep good
    alignment in later chunks.

So these have always been externally aligned. Correct the corresponding part of our documentation to reflect that.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 Documentation/gitformat-pack.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/gitformat-pack.txt b/Documentation/gitformat-pack.txt
index d7153962d4..54000c9412 100644
--- a/Documentation/gitformat-pack.txt
+++ b/Documentation/gitformat-pack.txt
@@ -392,8 +392,9 @@ CHUNK DATA:
 	Packfile Names (ID: {'P', 'N', 'A', 'M'})
 	    Stores the packfile names as concatenated, NUL-terminated strings.
 	    Packfiles must be listed in lexicographic order for fast lookups by
-	    name. This is the only chunk not guaranteed to be a multiple of four
-	    bytes in length, so should be the last chunk for alignment reasons.
+	    name. Individual entries in this chunk are not guarenteed to be
+	    aligned. The chunk is externally padded with zeros to align
+	    remaining chunks.
 
 	OID Fanout (ID: {'O', 'I', 'D', 'F'})
 	    The ith entry, F[i], stores the number of OIDs with first
-- 
2.42.0.349.gf0c1128f8b.dirty
Previous: Taylor BlauNext: Junio C Hamano
Message 3 of 10 in “Documentation/gitformat-pack.txt: correct a few issues/typos”
  1. 0/2 Documentation/gitformat-pack.txt: correct a few issues/typosTaylor Blau, Oct 12, 2023
  2. 1/2 Documentation/gitformat-pack.txt: fix typoTaylor Blau, Oct 12, 2023
  3. 2/2 Documentation/gitformat-pack.txt: fix incorrect MIDX documentationTaylor Blau, Oct 12, 2023
  4. Junio C HamanoOct 12, 2023
  5. Taylor BlauOct 30, 2023
  6. Junio C HamanoOct 31, 2023
  7. 0/2 Documentation/gitformat-pack.txt: correct a few issues/typosTaylor Blau, Oct 31, 2023
  8. 1/2 Documentation/gitformat-pack.txt: fix typoTaylor Blau, Oct 31, 2023
  9. 2/2 Documentation/gitformat-pack.txt: fix incorrect MIDX documentationTaylor Blau, Oct 31, 2023
  10. Jeff KingOct 31, 2023

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.