@matheusbsbs / matheus-bagliano / commits / 123712ba41
Fork 0

index-format.txt: document SHA-256 index format

Document that in SHA-1 repositories, we use SHA-1 and in SHA-256 repositories, we use SHA-256, then replace all other uses of "SHA-1" with something more neutral. Avoid referring to "160-bit" hash values. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Ågren committed Aug 15, 2020 at 18:06 UTC 123712ba41164146cd711dab6fe107b62d443f12
1 file changed +18 -16
Documentation/technical/index-format.txt
+18 -16
@@ -3,8 +3,11 @@ Git index format
3
4 == The Git index file has the following format
5
6 - All binary numbers are in network byte order. Version 2 is described
7 - here unless stated otherwise.
6 + All binary numbers are in network byte order.
7 + In a repository using the traditional SHA-1, checksums and object IDs
8 + (object names) mentioned below are all computed using SHA-1. Similarly,
9 + in SHA-256 repositories, these values are computed using SHA-256.
10 + Version 2 is described here unless stated otherwise.
11
12 - A 12-byte header consisting of
13
@@ -32,8 +35,7 @@ Git index format
35
36 Extension data
37
35 - - 160-bit SHA-1 over the content of the index file before this
36 - checksum.
38 + - Hash checksum over the content of the index file before this checksum.
39
40 == Index entry
41
@@ -80,7 +82,7 @@ Git index format
82 32-bit file size
83 This is the on-disk size from stat(2), truncated to 32-bit.
84
83 - 160-bit SHA-1 for the represented object
85 + Object name for the represented object
86
87 A 16-bit 'flags' field split into (high to low bits)
88
@@ -160,8 +162,8 @@ Git index format
162
163 - A newline (ASCII 10); and
164
163 - - 160-bit object name for the object that would result from writing
164 - this span of index as a tree.
165 + - Object name for the object that would result from writing this span
166 + of index as a tree.
167
168 An entry can be in an invalidated state and is represented by having
169 a negative number in the entry_count field. In this case, there is no
@@ -198,7 +200,7 @@ Git index format
200 stage 1 to 3 (a missing stage is represented by "0" in this field);
201 and
202
201 - - At most three 160-bit object names of the entry in stages from 1 to 3
203 + - At most three object names of the entry in stages from 1 to 3
204 (nothing is written for a missing stage).
205
206 === Split index
@@ -211,8 +213,8 @@ Git index format
213
214 The extension consists of:
215
214 - - 160-bit SHA-1 of the shared index file. The shared index file path
215 - is $GIT_DIR/sharedindex.<SHA-1>. If all 160 bits are zero, the
216 + - Hash of the shared index file. The shared index file path
217 + is $GIT_DIR/sharedindex.<hash>. If all bits are zero, the
218 index does not require a shared index file.
219
220 - An ewah-encoded delete bitmap, each bit represents an entry in the
@@ -253,10 +255,10 @@ Git index format
255
256 - 32-bit dir_flags (see struct dir_struct)
257
256 - - 160-bit SHA-1 of $GIT_DIR/info/exclude. Null SHA-1 means the file
258 + - Hash of $GIT_DIR/info/exclude. A null hash means the file
259 does not exist.
260
259 - - 160-bit SHA-1 of core.excludesfile. Null SHA-1 means the file does
261 + - Hash of core.excludesfile. A null hash means the file does
262 not exist.
263
264 - NUL-terminated string of per-dir exclude file name. This usually
@@ -285,13 +287,13 @@ The remaining data of each directory block is grouped by type:
287 - An ewah bitmap, the n-th bit records "check-only" bit of
288 read_directory_recursive() for the n-th directory.
289
288 - - An ewah bitmap, the n-th bit indicates whether SHA-1 and stat data
290 + - An ewah bitmap, the n-th bit indicates whether hash and stat data
291 is valid for the n-th directory and exists in the next data.
292
293 - An array of stat data. The n-th data corresponds with the n-th
294 "one" bit in the previous ewah bitmap.
295
294 - - An array of SHA-1. The n-th SHA-1 corresponds with the n-th "one" bit
296 + - An array of hashes. The n-th hash corresponds with the n-th "one" bit
297 in the previous ewah bitmap.
298
299 - One NUL.
@@ -330,12 +332,12 @@ The remaining data of each directory block is grouped by type:
332
333 - 32-bit offset to the end of the index entries
334
333 - - 160-bit SHA-1 over the extension types and their sizes (but not
335 + - Hash over the extension types and their sizes (but not
336 their contents). E.g. if we have "TREE" extension that is N-bytes
337 long, "REUC" extension that is M-bytes long, followed by "EOIE",
338 then the hash would be:
339
338 - SHA-1("TREE" + <binary representation of N> +
340 + Hash("TREE" + <binary representation of N> +
341 "REUC" + <binary representation of M>)
342
343 == Index Entry Offset Table