Skip to content

Commit 1bd8099

Browse files
ttaylorrgitster
authored andcommitted
Documentation/gitformat-pack.txt: fix incorrect MIDX documentation
Back in 32f3c54 (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. e0d1bcf 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 4-byte aligned since they are arbitrary strings, but the chunk itself is 4-byte aligned since the ending is padded with NUL bytes. That padding has always been there since 32f3c54 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, 32f3c54'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. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 530a9f1 commit 1bd8099

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Documentation/gitformat-pack.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,11 @@ CHUNK LOOKUP:
390390
CHUNK DATA:
391391

392392
Packfile Names (ID: {'P', 'N', 'A', 'M'})
393-
Stores the packfile names as concatenated, NUL-terminated strings.
394-
Packfiles must be listed in lexicographic order for fast lookups by
395-
name. This is the only chunk not guaranteed to be a multiple of four
396-
bytes in length, so should be the last chunk for alignment reasons.
393+
Store the names of packfiles as a sequence of NUL-terminated
394+
strings. There is no extra padding between the filenames,
395+
and they are listed in lexicographic order. The chunk itself
396+
is padded at the end with between 0 and 3 NUL bytes to make the
397+
chunk size a multiple of 4 bytes.
397398

398399
OID Fanout (ID: {'O', 'I', 'D', 'F'})
399400
The ith entry, F[i], stores the number of OIDs with first

0 commit comments

Comments
 (0)