{"thread":{"id":"64269","subject":"[PATCH v2 0/6] ci: improvements to our Rust infrastructure","startedAt":"2025-10-08T06:27:28Z","lastAt":"2025-10-09T19:29:34Z","messageCount":9,"participants":["Patrick Steinhardt","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":6},"messages":[{"id":"528202","messageId":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","threadId":"64269","inReplyTo":null,"subject":"[PATCH v2 0/6] ci: improvements to our Rust infrastructure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-08T06:27:11Z","receivedAt":"2025-10-08T06:27:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis small patch series introduces some improvements for our Rust\ninfrastructure. Most importantly, it introduces a couple of static\nanalysis checks to verify consistent formatting, use Clippy for linting\nand to verify our minimum supported Rust version.\n\nFurthermore, this series also introduces support for building with Rust\nenabled on Windows.\n\nThe series is built on top of 45547b60ac (Merge branch 'master' of\nhttps://github.com/j6t/gitk, 2025-10-05) with ps/rust-balloon at\ne425c40aa0 (ci: enable Rust for breaking-changes jobs, 2025-10-02) and\nps/gitlab-ci-windows-improvements at 3c4925c3f5 (t8020: fix test failure\ndue to indeterministic tag sorting, 2025-10-02) merged into it.\n\nChanges in v2:\n  - Adjust comments for `encode_varint()` and `decode_varint()` based on\n    brian's feedback.\n  - Some small improvements to commit messages.\n  - Not changed is the default column limit used by Rust. I think using\n    the column limit of 100 used by the Rust ecosystem is sensible, but\n    if there is a majority advocating for a limit of 80 I'll adapt this.\n  - Link to v1: https://lore.kernel.org/r/20251007-b4-pks-ci-rust-v1-0-394502abe7ea@pks.im\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (6):\n      ci: deduplicate calls to `apt-get update`\n      ci: check formatting of our Rust code\n      rust/varint: add safety comments\n      ci: check for common Rust mistakes via Clippy\n      ci: verify minimum supported Rust version\n      rust: support for Windows\n\n .github/workflows/main.yml | 15 +++++++++++++++\n .gitlab-ci.yml             | 13 ++++++++++++-\n Cargo.toml                 |  1 +\n Makefile                   | 14 ++++++++++++--\n ci/install-dependencies.sh | 17 +++++++++++++----\n ci/run-rust-checks.sh      | 22 ++++++++++++++++++++++\n meson.build                |  4 ++++\n src/cargo-meson.sh         | 11 +++++++++--\n src/varint.rs              | 15 +++++++++++++++\n 9 files changed, 103 insertions(+), 9 deletions(-)\n\nRange-diff versus v1:\n\n1:  26bd2c3713 ! 1:  fa3ba52997 ci: deduplicate calls to `apt-get update`\n    @@ Commit message\n         only required to perform job-specific tasks.\n     \n         In both steps we use `apt-get update` to update our repository sources.\n    -    This is unecessary though: all platforms that use Aptitude would have\n    +    This is unnecessary though: all platforms that use Aptitude would have\n         already executed this command in the distro-specific step anyway.\n     \n         Drop the redundant calls.\n2:  5116c20fd1 ! 2:  89e7b67d5c ci: check formatting of our Rust code\n    @@ Commit message\n         ci: check formatting of our Rust code\n     \n         Introduce a CI check that verifies that our Rust code is well-formatted.\n    -    This check uses rustfmt(1), which is the de-facto standard in the Rust\n    -    world.\n    +    This check uses `cargo fmt`, which is a wrapper around rustfmt(1) that\n    +    executes formatting for all Rust source files. rustfmt(1) itself is the\n    +    de-facto standard for formatting code in the Rust ecosystem.\n     \n         The rustfmt(1) tool allows to tweak the final format in theory. In\n         practice though, the Rust ecosystem has aligned on style \"editions\".\n3:  5b4c3303b7 < -:  ---------- rust/varint: add safety comments\n-:  ---------- > 3:  3c91ec55dc rust/varint: add safety comments\n4:  68925b41c0 = 4:  481500d7b8 ci: check for common Rust mistakes via Clippy\n5:  c3f0943066 = 5:  09e73796ec ci: verify minimum supported Rust version\n6:  0f968950a8 = 6:  acd460fac5 rust: support for Windows\n\n---\nbase-commit: 8c8e270f2aba359479c4c2b4ab3c62726e5dac9d\nchange-id: 20251007-b4-pks-ci-rust-8422e6a8196e\n\n"},{"id":"528203","messageId":"20251008-b4-pks-ci-rust-v2-1-d556ee83c381@pks.im","threadId":"64269","inReplyTo":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","subject":"[PATCH v2 1/6] ci: deduplicate calls to `apt-get update`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-08T06:27:12Z","receivedAt":"2025-10-08T06:27:30Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When installing dependencies we first check for the distribution that is\nin use and then we check for the specific job. In the first step we\nalready install all dependencies required to build and test Git, whereas\nthe second step installs a couple of additional dependencies that are\nonly required to perform job-specific tasks.\n\nIn both steps we use `apt-get update` to update our repository sources.\nThis is unnecessary though: all platforms that use Aptitude would have\nalready executed this command in the distro-specific step anyway.\n\nDrop the redundant calls.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n ci/install-dependencies.sh | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh\nindex 0d3aa496fc..645d035250 100755\n--- a/ci/install-dependencies.sh\n+++ b/ci/install-dependencies.sh\n@@ -120,21 +120,17 @@ esac\n \n case \"$jobname\" in\n ClangFormat)\n-\tsudo apt-get -q update\n \tsudo apt-get -q -y install clang-format\n \t;;\n StaticAnalysis)\n-\tsudo apt-get -q update\n \tsudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \\\n \t\tlibexpat-dev gettext make\n \t;;\n sparse)\n-\tsudo apt-get -q update -q\n \tsudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \\\n \t\tlibexpat-dev gettext zlib1g-dev sparse\n \t;;\n Documentation)\n-\tsudo apt-get -q update\n \tsudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make\n \n \ttest -n \"$ALREADY_HAVE_ASCIIDOCTOR\" ||\n\n-- \n2.51.0.764.g787ff6f08a.dirty\n\n"},{"id":"528204","messageId":"20251008-b4-pks-ci-rust-v2-2-d556ee83c381@pks.im","threadId":"64269","inReplyTo":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","subject":"[PATCH v2 2/6] ci: check formatting of our Rust code","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-08T06:27:13Z","receivedAt":"2025-10-08T06:27:33Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Introduce a CI check that verifies that our Rust code is well-formatted.\nThis check uses `cargo fmt`, which is a wrapper around rustfmt(1) that\nexecutes formatting for all Rust source files. rustfmt(1) itself is the\nde-facto standard for formatting code in the Rust ecosystem.\n\nThe rustfmt(1) tool allows to tweak the final format in theory. In\npractice though, the Rust ecosystem has aligned on style \"editions\".\nThese editions only exist to ensure that any potential changes to the\nstyle don't cause reformats to existing code bases. Other than that,\nmost Rust projects out there accept this default style of a specific\nedition.\n\nLet's do the same and use that default style. It may not be anyone's\nfavorite, but it is consistent and by making it part of our CI we also\nenforce it right from the start.\n\nNote that we don't have to pick a specific style edition here, as the\nedition is automatically derived from the edition we have specified in\nour \"Cargo.toml\" file.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n .github/workflows/main.yml | 15 +++++++++++++++\n .gitlab-ci.yml             | 11 +++++++++++\n ci/install-dependencies.sh |  5 +++++\n ci/run-rust-checks.sh      | 12 ++++++++++++\n 4 files changed, 43 insertions(+)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 393ea4d1cc..9e36b5c5e3 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -458,6 +458,21 @@ jobs:\n     - run: ci/install-dependencies.sh\n     - run: ci/run-static-analysis.sh\n     - run: ci/check-directional-formatting.bash\n+  rust-analysis:\n+    needs: ci-config\n+    if: needs.ci-config.outputs.enabled == 'yes'\n+    env:\n+      jobname: RustAnalysis\n+      CI_JOB_IMAGE: ubuntu:rolling\n+    runs-on: ubuntu-latest\n+    container: ubuntu:rolling\n+    concurrency:\n+      group: rust-analysis-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n+    steps:\n+    - uses: actions/checkout@v4\n+    - run: ci/install-dependencies.sh\n+    - run: ci/run-rust-checks.sh\n   sparse:\n     needs: ci-config\n     if: needs.ci-config.outputs.enabled == 'yes'\ndiff --git a/.gitlab-ci.yml b/.gitlab-ci.yml\nindex f7d57d1ee9..a47d839e39 100644\n--- a/.gitlab-ci.yml\n+++ b/.gitlab-ci.yml\n@@ -212,6 +212,17 @@ static-analysis:\n     - ./ci/run-static-analysis.sh\n     - ./ci/check-directional-formatting.bash\n \n+rust-analysis:\n+  image: ubuntu:rolling\n+  stage: analyze\n+  needs: [ ]\n+  variables:\n+    jobname: RustAnalysis\n+  before_script:\n+    - ./ci/install-dependencies.sh\n+  script:\n+    - ./ci/run-rust-checks.sh\n+\n check-whitespace:\n   image: ubuntu:latest\n   stage: analyze\ndiff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh\nindex 645d035250..a24b07edff 100755\n--- a/ci/install-dependencies.sh\n+++ b/ci/install-dependencies.sh\n@@ -126,6 +126,11 @@ StaticAnalysis)\n \tsudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \\\n \t\tlibexpat-dev gettext make\n \t;;\n+RustAnalysis)\n+\tsudo apt-get -q -y install rustup\n+\trustup default stable\n+\trustup component add rustfmt\n+\t;;\n sparse)\n \tsudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \\\n \t\tlibexpat-dev gettext zlib1g-dev sparse\ndiff --git a/ci/run-rust-checks.sh b/ci/run-rust-checks.sh\nnew file mode 100755\nindex 0000000000..082eb52f11\n--- /dev/null\n+++ b/ci/run-rust-checks.sh\n@@ -0,0 +1,12 @@\n+#!/bin/sh\n+\n+. ${0%/*}/lib.sh\n+\n+set +x\n+\n+if ! group \"Check Rust formatting\" cargo fmt --all --check\n+then\n+\tRET=1\n+fi\n+\n+exit $RET\n\n-- \n2.51.0.764.g787ff6f08a.dirty\n\n"},{"id":"528205","messageId":"20251008-b4-pks-ci-rust-v2-3-d556ee83c381@pks.im","threadId":"64269","inReplyTo":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","subject":"[PATCH v2 3/6] rust/varint: add safety comments","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-08T06:27:14Z","receivedAt":"2025-10-08T06:27:36Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `decode_varint()` and `encode_varint()` functions in our Rust crate\nare reimplementations of the respective C functions. As such, we are\nnaturally forced to use the same interface in both Rust and C, which\nmakes use of raw pointers. The consequence is that the code needs to be\nmarked as unsafe in Rust.\n\nIt is common practice in Rust to provide safety documentation for every\nblock that is marked as unsafe. This common practice is also enforced by\nClippy, Rust's static analyser. We don't have Clippy wired up yet, and\nwe could of course just disable this check. But we're about to wire it\nup, and it is reasonable to always enforce documentation for unsafe\nblocks.\n\nAdd such safety comments to already squelch those warnings now. While at\nit, also document the functions' behaviour.\n\nHelped-by: \"brian m. carlson\" <sandals@crustytoothpaste.net>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n src/varint.rs | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)\n\ndiff --git a/src/varint.rs b/src/varint.rs\nindex 6e610bdd8e..06492dfc5e 100644\n--- a/src/varint.rs\n+++ b/src/varint.rs\n@@ -1,3 +1,10 @@\n+/// Decode the variable-length integer stored in `bufp` and return the decoded value.\n+///\n+/// Returns 0 in case the decoded integer would overflow u64::MAX.\n+///\n+/// # Safety\n+///\n+/// The buffer must be NUL-terminated to ensure safety.\n #[no_mangle]\n pub unsafe extern \"C\" fn decode_varint(bufp: *mut *const u8) -> u64 {\n     let mut buf = *bufp;\n@@ -22,6 +29,14 @@ pub unsafe extern \"C\" fn decode_varint(bufp: *mut *const u8) -> u64 {\n     val\n }\n \n+/// Encode `value` into `buf` as a variable-length integer unless `buf` is null.\n+///\n+/// Returns the number of bytes written, or, if `buf` is null, the number of bytes that would be\n+/// written to encode the integer.\n+///\n+/// # Safety\n+///\n+/// `buf` must either be null or point to at least 16 bytes of memory.\n #[no_mangle]\n pub unsafe extern \"C\" fn encode_varint(value: u64, buf: *mut u8) -> u8 {\n     let mut varint: [u8; 16] = [0; 16];\n\n-- \n2.51.0.764.g787ff6f08a.dirty\n\n"},{"id":"528206","messageId":"20251008-b4-pks-ci-rust-v2-4-d556ee83c381@pks.im","threadId":"64269","inReplyTo":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","subject":"[PATCH v2 4/6] ci: check for common Rust mistakes via Clippy","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-08T06:27:15Z","receivedAt":"2025-10-08T06:27:40Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Introduce a CI check that uses Clippy to perform checks for common\nmistakes and suggested code improvements. Clippy is the official static\nanalyser of the Rust project and thus the de-facto standard.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n ci/install-dependencies.sh | 2 +-\n ci/run-rust-checks.sh      | 5 +++++\n 2 files changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh\nindex a24b07edff..dcd22ddd95 100755\n--- a/ci/install-dependencies.sh\n+++ b/ci/install-dependencies.sh\n@@ -129,7 +129,7 @@ StaticAnalysis)\n RustAnalysis)\n \tsudo apt-get -q -y install rustup\n \trustup default stable\n-\trustup component add rustfmt\n+\trustup component add clippy rustfmt\n \t;;\n sparse)\n \tsudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \\\ndiff --git a/ci/run-rust-checks.sh b/ci/run-rust-checks.sh\nindex 082eb52f11..fb5ea8991b 100755\n--- a/ci/run-rust-checks.sh\n+++ b/ci/run-rust-checks.sh\n@@ -9,4 +9,9 @@ then\n \tRET=1\n fi\n \n+if ! group \"Check for common Rust mistakes\" cargo clippy --all-targets --all-features -- -Dwarnings\n+then\n+\tRET=1\n+fi\n+\n exit $RET\n\n-- \n2.51.0.764.g787ff6f08a.dirty\n\n"},{"id":"528207","messageId":"20251008-b4-pks-ci-rust-v2-5-d556ee83c381@pks.im","threadId":"64269","inReplyTo":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","subject":"[PATCH v2 5/6] ci: verify minimum supported Rust version","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-08T06:27:16Z","receivedAt":"2025-10-08T06:27:43Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In the current state of our Rust code base we don't really have any\nrequirements for the minimum supported Rust version yet, as we don't use\nany features introduced by a recent version of Rust. Consequently, we\nhave decided that we want to aim for a rather old version and edition of\nRust, where the hope is that using an old version will make alternatives\nlike gccrs viable earlier for compiling Git.\n\nBut while we specify the Rust edition, we don't yet specify a Rust\nversion. And even if we did, the Rust version would only be enforced for\nour own code, but not for any of our dependencies.\n\nWe don't yet have any dependencies at the current point in time. But\nlet's add some safeguards by specifying the minimum supported Rust\nversion and using cargo-msrv(1) to verify that this version can be\nsatisfied for all of our dependencies.\n\nNote that we fix the version of cargo-msrv(1) at v0.18.1. This is the\nlatest release supported by Ubuntu's Rust version.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Cargo.toml                 | 1 +\n ci/install-dependencies.sh | 8 ++++++++\n ci/run-rust-checks.sh      | 5 +++++\n 3 files changed, 14 insertions(+)\n\ndiff --git a/Cargo.toml b/Cargo.toml\nindex 45c9b34981..2f51bf5d5f 100644\n--- a/Cargo.toml\n+++ b/Cargo.toml\n@@ -2,6 +2,7 @@\n name = \"gitcore\"\n version = \"0.1.0\"\n edition = \"2018\"\n+rust-version = \"1.49.0\"\n \n [lib]\n crate-type = [\"staticlib\"]\ndiff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh\nindex dcd22ddd95..29e558bb9c 100755\n--- a/ci/install-dependencies.sh\n+++ b/ci/install-dependencies.sh\n@@ -10,6 +10,8 @@ begin_group \"Install dependencies\"\n P4WHENCE=https://cdist2.perforce.com/perforce/r23.2\n LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION\n JGITWHENCE=https://repo1.maven.org/maven2/org/eclipse/jgit/org.eclipse.jgit.pgm/6.8.0.202311291450-r/org.eclipse.jgit.pgm-6.8.0.202311291450-r.sh\n+CARGO_MSRV_VERSION=0.18.4\n+CARGO_MSRV_WHENCE=https://github.com/foresterre/cargo-msrv/releases/download/v$CARGO_MSRV_VERSION/cargo-msrv-x86_64-unknown-linux-musl-v$CARGO_MSRV_VERSION.tgz\n \n # Make sudo a no-op and execute the command directly when running as root.\n # While using sudo would be fine on most platforms when we are root already,\n@@ -130,6 +132,12 @@ RustAnalysis)\n \tsudo apt-get -q -y install rustup\n \trustup default stable\n \trustup component add clippy rustfmt\n+\n+\twget -q \"$CARGO_MSRV_WHENCE\" -O \"cargo-msvc.tgz\"\n+\tsudo mkdir -p \"$CUSTOM_PATH\"\n+\tsudo tar -xf \"cargo-msvc.tgz\" --strip-components=1 \\\n+\t\t--directory \"$CUSTOM_PATH\" --wildcards \"*/cargo-msrv\"\n+\tsudo chmod a+x \"$CUSTOM_PATH/cargo-msrv\"\n \t;;\n sparse)\n \tsudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \\\ndiff --git a/ci/run-rust-checks.sh b/ci/run-rust-checks.sh\nindex fb5ea8991b..b5ad9e8dc6 100755\n--- a/ci/run-rust-checks.sh\n+++ b/ci/run-rust-checks.sh\n@@ -14,4 +14,9 @@ then\n \tRET=1\n fi\n \n+if ! group \"Check for minimum required Rust version\" cargo msrv verify\n+then\n+\tRET=1\n+fi\n+\n exit $RET\n\n-- \n2.51.0.764.g787ff6f08a.dirty\n\n"},{"id":"528208","messageId":"20251008-b4-pks-ci-rust-v2-6-d556ee83c381@pks.im","threadId":"64269","inReplyTo":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","subject":"[PATCH v2 6/6] rust: support for Windows","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-08T06:27:17Z","receivedAt":"2025-10-08T06:27:46Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The initial patch series that introduced Rust into the core of Git only\ncared about macOS and Linux. This specifically leaves out Windows, which\nindeed fails to build right now due to two issues:\n\n  - The Rust runtime requires `GetUserProfileDirectoryW()`, but we don't\n    link against \"userenv.dll\".\n\n  - The path of the Rust library built on Windows is different than on\n    most other systems systems.\n\nFix both of these issues to support Windows.\n\nNote that this commit fixes the Meson-based job in GitHub's CI. Meson\nauto-detects the availability of Rust, and as the Windows runner has\nRust installed by default it already enabled Rust support there. But due\nto the above issues that job fails consistently.\n\nInstall Rust on GitLab CI, as well, to improve test coverage there.\n\nBased-on-patch-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nBased-on-patch-by: Ezekiel Newren <ezekielnewren@gmail.com>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n .gitlab-ci.yml     |  2 +-\n Makefile           | 14 ++++++++++++--\n meson.build        |  4 ++++\n src/cargo-meson.sh | 11 +++++++++--\n 4 files changed, 26 insertions(+), 5 deletions(-)\n\ndiff --git a/.gitlab-ci.yml b/.gitlab-ci.yml\nindex a47d839e39..b419a84e2c 100644\n--- a/.gitlab-ci.yml\n+++ b/.gitlab-ci.yml\n@@ -161,7 +161,7 @@ test:mingw64:\n     - saas-windows-medium-amd64\n   before_script:\n     - *windows_before_script\n-    - choco install -y git meson ninja\n+    - choco install -y git meson ninja rust-ms\n     - Import-Module $env:ChocolateyInstall\\helpers\\chocolateyProfile.psm1\n     - refreshenv\n \ndiff --git a/Makefile b/Makefile\nindex 7ea149598d..366fd173e7 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -929,10 +929,17 @@ TEST_SHELL_PATH = $(SHELL_PATH)\n LIB_FILE = libgit.a\n XDIFF_LIB = xdiff/lib.a\n REFTABLE_LIB = reftable/libreftable.a\n+\n ifdef DEBUG\n-RUST_LIB = target/debug/libgitcore.a\n+RUST_TARGET_DIR = target/debug\n else\n-RUST_LIB = target/release/libgitcore.a\n+RUST_TARGET_DIR = target/release\n+endif\n+\n+ifeq ($(uname_S),Windows)\n+RUST_LIB = $(RUST_TARGET_DIR)/gitcore.lib\n+else\n+RUST_LIB = $(RUST_TARGET_DIR)/libgitcore.a\n endif\n \n # xdiff and reftable libs may in turn depend on what is in libgit.a\n@@ -1538,6 +1545,9 @@ ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND)\n ifdef WITH_RUST\n BASIC_CFLAGS += -DWITH_RUST\n GITLIBS += $(RUST_LIB)\n+ifeq ($(uname_S),Windows)\n+EXTLIBS += -luserenv\n+endif\n endif\n \n ifdef SANITIZE\ndiff --git a/meson.build b/meson.build\nindex ec55d6a5fd..a9c865b2af 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1707,6 +1707,10 @@ rust_option = get_option('rust').disable_auto_if(not cargo.found())\n if rust_option.allowed()\n   subdir('src')\n   libgit_c_args += '-DWITH_RUST'\n+\n+  if host_machine.system() == 'windows'\n+    libgit_dependencies += compiler.find_library('userenv')\n+  endif\n else\n   libgit_sources += [\n     'varint.c',\ndiff --git a/src/cargo-meson.sh b/src/cargo-meson.sh\nindex 99400986d9..3998db0435 100755\n--- a/src/cargo-meson.sh\n+++ b/src/cargo-meson.sh\n@@ -26,7 +26,14 @@ then\n \texit $RET\n fi\n \n-if ! cmp \"$BUILD_DIR/$BUILD_TYPE/libgitcore.a\" \"$BUILD_DIR/libgitcore.a\" >/dev/null 2>&1\n+case \"$(cargo -vV | sed -s 's/^host: \\(.*\\)$/\\1/')\" in\n+\t*-windows-*)\n+\t\tLIBNAME=gitcore.lib;;\n+\t*)\n+\t\tLIBNAME=libgitcore.a;;\n+esac\n+\n+if ! cmp \"$BUILD_DIR/$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\" >/dev/null 2>&1\n then\n-\tcp \"$BUILD_DIR/$BUILD_TYPE/libgitcore.a\" \"$BUILD_DIR/libgitcore.a\"\n+\tcp \"$BUILD_DIR/$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\"\n fi\n\n-- \n2.51.0.764.g787ff6f08a.dirty\n\n"},{"id":"528239","messageId":"aOZTOs5Z9QyfRXYO@pks.im","threadId":"64269","inReplyTo":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","subject":"Re: [PATCH v2 0/6] ci: improvements to our Rust infrastructure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-08T12:04:10Z","receivedAt":"2025-10-08T12:04:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Oct 08, 2025 at 08:27:11AM +0200, Patrick Steinhardt wrote:\n> Hi,\n> \n> this small patch series introduces some improvements for our Rust\n> infrastructure. Most importantly, it introduces a couple of static\n> analysis checks to verify consistent formatting, use Clippy for linting\n> and to verify our minimum supported Rust version.\n> \n> Furthermore, this series also introduces support for building with Rust\n> enabled on Windows.\n> \n> The series is built on top of 45547b60ac (Merge branch 'master' of\n> https://github.com/j6t/gitk, 2025-10-05) with ps/rust-balloon at\n> e425c40aa0 (ci: enable Rust for breaking-changes jobs, 2025-10-02) and\n> ps/gitlab-ci-windows-improvements at 3c4925c3f5 (t8020: fix test failure\n> due to indeterministic tag sorting, 2025-10-02) merged into it.\n> \n> Changes in v2:\n>   - Adjust comments for `encode_varint()` and `decode_varint()` based on\n>     brian's feedback.\n>   - Some small improvements to commit messages.\n>   - Not changed is the default column limit used by Rust. I think using\n>     the column limit of 100 used by the Rust ecosystem is sensible, but\n>     if there is a majority advocating for a limit of 80 I'll adapt this.\n>   - Link to v1: https://lore.kernel.org/r/20251007-b4-pks-ci-rust-v1-0-394502abe7ea@pks.im\n\nSorry, I noticed that threading is broken here. An update of b4 made me\nlose my custom patches that implement shallow threading by accident. The\nnext version will connect back to the original thread again.\n\nPatrick\n"},{"id":"528397","messageId":"xmqqa51zeuw4.fsf@gitster.g","threadId":"64269","inReplyTo":"20251008-b4-pks-ci-rust-v2-0-d556ee83c381@pks.im","subject":"Re: [PATCH v2 0/6] ci: improvements to our Rust infrastructure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-09T19:29:31Z","receivedAt":"2025-10-09T19:29:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Changes in v2:\n>   - Adjust comments for `encode_varint()` and `decode_varint()` based on\n>     brian's feedback.\n>   - Some small improvements to commit messages.\n>   - Not changed is the default column limit used by Rust. I think using\n>     the column limit of 100 used by the Rust ecosystem is sensible, but\n>     if there is a majority advocating for a limit of 80 I'll adapt this.\n>   - Link to v1: https://lore.kernel.org/r/20251007-b4-pks-ci-rust-v1-0-394502abe7ea@pks.im\n\nOK.  I am ambivalent on the column limit one, but otherwise, this\ntopic looks quite well done already.\n\nThanks.\n"}]}