This patch series involves ZERO Rust code and toolchains, which avoids the debate about Rust's portability and timeline. Instead, it shows how Git can immediately benefit from Rust's design choices without using it at all. The rationale for using Rust types on the C and Rust side is addressed in the commit that creates compat/rust_types.h. This patch series has 2 parts: * Patches 1-9: Clean up xdiff, this can be merged without part 2. * Patches 10-17: Define Rust types in compat/rust_types.h and then start refactoring xdiff with Rust types. This depends on part 1. The cleanup in this patch series makes the structs xrecord_t and xdfile_t Rust FFI friendly. My opinion is that part 1 should be merged soon, while part 2 can be discussed further. Before: typedef struct s_xrecord { struct s_xrecord *next; char const *ptr; long size; unsigned long ha; } xrecord_t; typedef struct s_xdfile { chastore_t rcha; long nrec; unsigned int hbits; xrecord_t **rhash; long dstart, dend; xrecord_t **recs; char *rchg; long *rindex; long nreff; unsigned long *ha; } xdfile_t; After cleanup: typedef struct s_xrecord { char const *ptr; long size; unsigned long ha; } xrecord_t; typedef struct s_xdfile { xrecord_t *recs; long nrec; long dstart, dend; char *rchg; long *rindex; long nreff; } xdfile_t; After using Rust types: typedef struct s_xrecord { u8 const *ptr; usize size; u64 line_hash; usize minimal_perfect_hash; } xrecord_t; typedef struct s_xdfile { xrecord_t *recs; usize nrec; i32 dstart, dend; u8 *rchg; usize *rindex; usize nreff; } xdfile_t; Ezekiel Newren (17): xdiff: delete static forward declarations in xprepare xdiff: delete local variables and initialize/free xdfile_t directly xdiff: delete unnecessary fields from xrecord_t and xdfile_t xdiff: delete xdl_get_rec() in xemit xdiff: delete struct diffdata_t xdiff: delete redundant array xdfile_t.ha xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t xdiff: delete chastore from xdfile_t, view with --color-words xdiff: treat xdfile_t.rchg like an enum compat/rust_types.h: define rust primitive types xdiff: include compat/rust_types.h xdiff: make xrecord_t.ptr a u8 instead of char xdiff: make xrecord_t.size a usize instead of long xdiff: split xrecord_t.ha into line_hash and minimal_perfect_hash xdiff: make xdfile_t.nrec a usize instead of long xdiff: make xdfile_t.nreff a usize instead of long xdiff: change the types of dstart, dend, rchg, and rindex in xdfile_t compat/rust_types.h | 28 +++++ xdiff/xdiff.h | 4 + xdiff/xdiffi.c | 118 ++++++++---------- xdiff/xdiffi.h | 11 +- xdiff/xemit.c | 52 +++----- xdiff/xhistogram.c | 14 +-- xdiff/xinclude.h | 1 + xdiff/xmacros.h | 2 +- xdiff/xmerge.c | 66 +++++----- xdiff/xpatience.c | 28 ++--- xdiff/xprepare.c | 289 +++++++++++++++++--------------------------- xdiff/xtypes.h | 26 ++-- xdiff/xutils.c | 12 +- 13 files changed, 293 insertions(+), 358 deletions(-) create mode 100644 compat/rust_types.h base-commit: 16bd9f20a403117f2e0d9bcda6c6e621d3763e77 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2048%2Fezekielnewren%2Fuse_rust_types_in_xdiff-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2048/ezekielnewren/use_rust_types_in_xdiff-v1 Pull-Request: https://github.com/git/git/pull/2048 -- gitgitgadget