1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 15:57:07 +00:00

doc: JSON encoder must be deterministic

This commit is contained in:
Michael Eischer 2024-08-26 14:40:04 +02:00
parent 71e8068d86
commit 7ea558db99

View file

@ -233,7 +233,9 @@ Individual files for the index, locks or snapshots are encrypted
and authenticated like Data and Tree Blobs, so the outer structure is and authenticated like Data and Tree Blobs, so the outer structure is
``IV || Ciphertext || MAC`` again. In repository format version 1 the ``IV || Ciphertext || MAC`` again. In repository format version 1 the
plaintext always consists of a JSON document which must either be an plaintext always consists of a JSON document which must either be an
object or an array. object or an array. The JSON encoder must deterministically encode the
document and should match the behavior of the Go standard library implementation
in ``encoding/json``.
Repository format version 2 adds support for compression. The plaintext Repository format version 2 adds support for compression. The plaintext
now starts with a header to indicate the encoding version to distinguish now starts with a header to indicate the encoding version to distinguish
@ -472,6 +474,10 @@ A snapshot references a tree by the SHA-256 hash of the JSON string
representation of its contents. Trees and data are saved in pack files representation of its contents. Trees and data are saved in pack files
in a subdirectory of the directory ``data``. in a subdirectory of the directory ``data``.
The JSON encoder must deterministically encode the document and should
match the behavior of the Go standard library implementation in ``encoding/json``.
This ensures that trees can be properly deduplicated.
The command ``restic cat blob`` can be used to inspect the tree The command ``restic cat blob`` can be used to inspect the tree
referenced above (piping the output of the command to ``jq .`` so that referenced above (piping the output of the command to ``jq .`` so that
the JSON is indented): the JSON is indented):