Skip to content

SHA-1/SHA-256 interoperability, part 2

brian m. carlson git 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest16 patches 0 repliesNew
  2. v215 patches 0 repliesSuperseded
  3. v114 patches 70 repliesSuperseded

Changes in v3 from the cover letter

* Rebase on master.
* Fix CI failure on Windows by adjusting path.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16repository: require Rust support for interoperabilityrepository.c t/t1006-cat-file.sh t/t1016-compatObjectFormat.sh +4 more+77 -330 replies
2/16conversion: don't crash when no destination algoobject-file-convert.c+1 -10 replies
3/16hash: use uint32_t for object_id algorithmhash.c hash.h oidtree.c +3 more+15 -150 replies
4/16rust: add a ObjectID structMakefile src/hash.rs src/lib.rs +1 more+24 -00 replies
5/16rust: add a hash algorithm abstractionsrc/hash.rs+159 -00 replies
6/16hash: add a function to look up hash algo structshash.c hash.h src/hash.rs+22 -00 replies
7/16rust: add additional helpers for ObjectIDsrc/hash.rs+132 -10 replies
8/16csum-file: define hashwrite's count as a uint32_tcsum-file.c csum-file.h+2 -20 replies
9/16write-or-die: add an fsync component for the object mapwrite-or-die.h+3 -10 replies
10/16hash: expose hash context functions to Rusthash.c hash.h+42 -200 replies
11/16rust: fix linking binaries with cargosrc/cargo-meson.sh+12 -70 replies
12/16rust: add a build.rs script for testsMakefile build.rs+18 -10 replies
13/16rust: add functionality to hash an objectsrc/hash.rs+142 -10 replies
14/16rust: add a new binary object map formatDocumentation/gitformat-loose.adoc Makefile src/lib.rs +2 more+994 -00 replies
15/16rust: add a small wrapper around the hashfile codeMakefile src/csum_file.rs src/lib.rs +1 more+84 -00 replies
16/16object-file-convert: always make sure object ID algo is validobject-file-convert.c+10 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 00/16] SHA-1/SHA-256 interoperability, part 2

This is the second part of the SHA-1/SHA-256 interoperability work. It introduces our first major use of Rust code to implement a object map format as well as preparatory work to make that happen, including changing types to more Rust-friendly ones. Since Rust will be required for the interoperability work, we require that in the testsuite.

We also verify that our object ID algorithm is valid when looking up data in the hash map since the Rust code intentionally has no knowledge about global mutable state like the_repository and so cannot default to the main hash algorithm when we've zero-initialized a struct object_id.

The advantage to this Rust code is that it is comprehensively tested with unit testing. We can serialize our object map and then verify that we can also load it again and perform various testing, such as whether certain object IDs are found in the map and mapped correctly. We can also test our slightly subtle custom binary search code effectively and be confident that it works, since Rust doesn't provide a way to binary search slices of variable length.

Changes since v2:

* Rebase on master.
* Fix CI failure on Windows by adjusting path.

Changes since v1:

* Use MAYBE_UNUSED instead of casting.
* Explain reason for ObjectID structure.
* Switch to Result in hash algorithm abstraction.
* Add some additional helpers to ObjectID.
* Rename function to hash_algo_ptr_by_number.
* Switch to xmalloc.
* Fix build.rs to use syntax compatible with Rust 1.63.
* Remove unneeded libraries from build.rs.
* Improve Rust documentation.
* Explain that safe hashing is about untrusted data, not memory safety.
* Add a trait for hashing to allow for future unsafe (trusted data) hashing.
* Rename Hasher to CryptoHasher.
* Remove description of legacy loose object map.
* Rename loose object map to object map.
* Update documentation for object map to be clearer about padding, alignment, and endianness.
* Explain which hash algorithm is used in object map.
* Remove mention of chunks in object map in favour of generic "additional data".
* Fix indentation in object map documentation.
* Generally clarify object map documentation.
* Fix clippy warnings in Rust code.

brian m. carlson (16):
repository: require Rust support for interoperability
conversion: don't crash when no destination algo
hash: use uint32_t for object_id algorithm
rust: add a ObjectID struct
rust: add a hash algorithm abstraction
hash: add a function to look up hash algo structs
rust: add additional helpers for ObjectID
csum-file: define hashwrite's count as a uint32_t
write-or-die: add an fsync component for the object map
hash: expose hash context functions to Rust
rust: fix linking binaries with cargo
rust: add a build.rs script for tests
rust: add functionality to hash an object
rust: add a new binary object map format
rust: add a small wrapper around the hashfile code
object-file-convert: always make sure object ID algo is valid

 Documentation/gitformat-loose.adoc |  78 +++
 Makefile                           |   5 +-
 build.rs                           |  17 +
 csum-file.c                        |   2 +-
 csum-file.h                        |   2 +-
 hash.c                             |  48 +-
 hash.h                             |  38 +-
 object-file-convert.c              |  14 +-
 oidtree.c                          |   2 +-
 repository.c                       |  12 +-
 repository.h                       |   4 +-
 serve.c                            |   2 +-
 src/cargo-meson.sh                 |  19 +-
 src/csum_file.rs                   |  81 +++
 src/hash.rs                        | 466 +++++++++++++++
 src/lib.rs                         |   3 +
 src/loose.rs                       | 913 +++++++++++++++++++++++++++++
 src/meson.build                    |   3 +
 t/t1006-cat-file.sh                |  82 ++-
 t/t1016-compatObjectFormat.sh      |   6 +
 t/t1500-rev-parse.sh               |   2 +-
 t/t9305-fast-import-signatures.sh  |   4 +-
 t/t9350-fast-export.sh             |   4 +-
 t/test-lib.sh                      |   4 +
 write-or-die.h                     |   4 +-
 25 files changed, 1734 insertions(+), 81 deletions(-)
 create mode 100644 build.rs
 create mode 100644 src/csum_file.rs
 create mode 100644 src/hash.rs
 create mode 100644 src/loose.rs