From a95677468bb30c56165b4ca9dd0098a85e482b42 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 9 Feb 2026 16:24:16 +0100 Subject: [PATCH 1/2] apply WD-40 in order to maintain platform / cpu-arch compatibility Signed-off-by: Enrico Weigelt, metux IT consult --- .github/workflows/main.yml | 15 --- .gitignore | 2 - .gitlab-ci.yml | 13 +-- Cargo.toml | 10 -- Documentation/BreakingChanges.adoc | 45 --------- Documentation/technical/build-systems.adoc | 6 -- Makefile | 92 ------------------ README.md | 2 + ci/install-dependencies.sh | 11 --- ci/run-build-and-tests.sh | 2 +- ci/run-rust-checks.sh | 22 ----- contrib/libgit-rs/Cargo.lock | 77 --------------- contrib/libgit-rs/Cargo.toml | 17 ---- contrib/libgit-rs/README.md | 13 --- contrib/libgit-rs/build.rs | 4 - contrib/libgit-rs/src/config.rs | 106 -------------------- contrib/libgit-rs/src/lib.rs | 1 - contrib/libgit-rs/testdata/config1 | 2 - contrib/libgit-rs/testdata/config2 | 2 - contrib/libgit-rs/testdata/config3 | 2 - contrib/libgit-sys/Cargo.lock | 69 ------------- contrib/libgit-sys/Cargo.toml | 19 ---- contrib/libgit-sys/README.md | 4 - contrib/libgit-sys/build.rs | 35 ------- contrib/libgit-sys/public_symbol_export.c | 59 ------------ contrib/libgit-sys/public_symbol_export.h | 18 ---- contrib/libgit-sys/src/lib.rs | 79 --------------- help.c | 7 +- meson.build | 15 +-- src/cargo-meson.sh | 39 -------- src/lib.rs | 1 - src/meson.build | 41 -------- src/varint.rs | 107 --------------------- t/Makefile | 3 - 34 files changed, 7 insertions(+), 933 deletions(-) delete mode 100644 Cargo.toml delete mode 100755 ci/run-rust-checks.sh delete mode 100644 contrib/libgit-rs/Cargo.lock delete mode 100644 contrib/libgit-rs/Cargo.toml delete mode 100644 contrib/libgit-rs/README.md delete mode 100644 contrib/libgit-rs/build.rs delete mode 100644 contrib/libgit-rs/src/config.rs delete mode 100644 contrib/libgit-rs/src/lib.rs delete mode 100644 contrib/libgit-rs/testdata/config1 delete mode 100644 contrib/libgit-rs/testdata/config2 delete mode 100644 contrib/libgit-rs/testdata/config3 delete mode 100644 contrib/libgit-sys/Cargo.lock delete mode 100644 contrib/libgit-sys/Cargo.toml delete mode 100644 contrib/libgit-sys/README.md delete mode 100644 contrib/libgit-sys/build.rs delete mode 100644 contrib/libgit-sys/public_symbol_export.c delete mode 100644 contrib/libgit-sys/public_symbol_export.h delete mode 100644 contrib/libgit-sys/src/lib.rs delete mode 100755 src/cargo-meson.sh delete mode 100644 src/lib.rs delete mode 100644 src/meson.build delete mode 100644 src/varint.rs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f2e93f54611b62..88eb5d3c67e08e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -468,21 +468,6 @@ jobs: - run: ci/install-dependencies.sh - run: ci/run-static-analysis.sh - run: ci/check-directional-formatting.bash - rust-analysis: - needs: ci-config - if: needs.ci-config.outputs.enabled == 'yes' - env: - jobname: RustAnalysis - CI_JOB_IMAGE: ubuntu:rolling - runs-on: ubuntu-latest - container: ubuntu:rolling - concurrency: - group: rust-analysis-${{ github.ref }} - cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }} - steps: - - uses: actions/checkout@v4 - - run: ci/install-dependencies.sh - - run: ci/run-rust-checks.sh sparse: needs: ci-config if: needs.ci-config.outputs.enabled == 'yes' diff --git a/.gitignore b/.gitignore index 78a45cb5bec991..85a8707523ff3c 100644 --- a/.gitignore +++ b/.gitignore @@ -256,5 +256,3 @@ Release/ /git.VC.db *.dSYM /contrib/buildsystems/out -/contrib/libgit-rs/target -/contrib/libgit-sys/target diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b419a84e2cc660..f7d57d1ee96528 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -161,7 +161,7 @@ test:mingw64: - saas-windows-medium-amd64 before_script: - *windows_before_script - - choco install -y git meson ninja rust-ms + - choco install -y git meson ninja - Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 - refreshenv @@ -212,17 +212,6 @@ static-analysis: - ./ci/run-static-analysis.sh - ./ci/check-directional-formatting.bash -rust-analysis: - image: ubuntu:rolling - stage: analyze - needs: [ ] - variables: - jobname: RustAnalysis - before_script: - - ./ci/install-dependencies.sh - script: - - ./ci/run-rust-checks.sh - check-whitespace: image: ubuntu:latest stage: analyze diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 2f51bf5d5ff5f8..00000000000000 --- a/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "gitcore" -version = "0.1.0" -edition = "2018" -rust-version = "1.49.0" - -[lib] -crate-type = ["staticlib"] - -[dependencies] diff --git a/Documentation/BreakingChanges.adoc b/Documentation/BreakingChanges.adoc index f814450d2f65ac..c874b208ba6be2 100644 --- a/Documentation/BreakingChanges.adoc +++ b/Documentation/BreakingChanges.adoc @@ -170,52 +170,7 @@ JGit, libgit2 and Gitoxide need to support it. provide useful advice about init.defaultBranch, 2020-12-11). The new name matches the default branch name used in new repositories by many of the big Git forges. - -* Git will require Rust as a mandatory part of the build process. While Git - already started to adopt Rust in Git 2.49, all parts written in Rust are - optional for the time being. This includes: -+ - ** The Rust wrapper around libgit.a that is part of "contrib/" and which has - been introduced in Git 2.49. - ** Subsystems that have an alternative implementation in Rust to test - interoperability between our C and Rust codebase. - ** Newly written features that are not mission critical for a fully functional - Git client. -+ -These changes are meant as test balloons to allow distributors of Git to prepare -for Rust becoming a mandatory part of the build process. There will be multiple -milestones for the introduction of Rust: -+ --- -1. Initially, with Git 2.52, support for Rust will be auto-detected by Meson and - disabled in our Makefile so that the project can sort out the initial - infrastructure. -2. In Git 2.53, both build systems will default-enable support for Rust. - Consequently, builds will break by default if Rust is not available on the - build host. The use of Rust can still be explicitly disabled via build - flags. -3. In Git 3.0, the build options will be removed and support for Rust is - mandatory. --- + -You can explicitly ask both Meson and our Makefile-based system to enable Rust -by saying `meson configure -Drust=enabled` and `make WITH_RUST=YesPlease`, -respectively. -+ -The Git project will declare the last version before Git 3.0 to be a long-term -support release. This long-term release will receive important bug fixes for at -least four release cycles and security fixes for six release cycles. The Git -project will hand over maintainership of the long-term release to distributors -in case they need to extend the life of that long-term release even further. -Details of how this long-term release will be handed over to the community will -be discussed once the Git project decides to stop officially supporting it. -+ -We will evaluate the impact on downstream distributions before making Rust -mandatory in Git 3.0. If we see that the impact on downstream distributions -would be significant, we may decide to defer this change to a subsequent minor -release. This evaluation will also take into account our own experience with -how painful it is to keep Rust an optional component. - === Removals * Support for grafting commits has long been superseded by git-replace(1). diff --git a/Documentation/technical/build-systems.adoc b/Documentation/technical/build-systems.adoc index 3c5237b9fd4727..b910026b536801 100644 --- a/Documentation/technical/build-systems.adoc +++ b/Documentation/technical/build-systems.adoc @@ -106,8 +106,6 @@ by the build system: - C: the primary compiled language used by Git, must be supported. Relevant toolchains are GCC, Clang and MSVC. - - Rust: candidate as a second compiled lanugage, should be supported. Relevant - toolchains is the LLVM-based rustc. Built-in support for the respective languages is preferred over support that needs to be wired up manually to avoid unnecessary complexity. Native support @@ -151,7 +149,6 @@ The following list of build systems are considered: - Cross-platform builds: supported in theory, not wired up in practice. - Language support: - C: Limited built-in support, many parts need to be wired up manually. - - Rust: No built-in support, needs to be wired up manually. - Test integration: partially supported, many parts need to be wired up manually. @@ -168,7 +165,6 @@ The following list of build systems are considered: - Cross-platform builds: supported. - Language support: - C: Limited built-in support, many parts need to be wired up manually. - - Rust: No built-in support, needs to be wired up manually. - Test integration: partially supported, many parts need to be wired up manually. @@ -194,7 +190,6 @@ The following list of build systems are considered: - Cross-platform builds: supported. - Language support: - C: Supported for GCC, Clang, MSVC and other toolchains. - - Rust: No built-in support, needs to be wired up manually. - Test integration: supported, even though test dependencies are a bit cumbersome to use via "test fixtures". Interactive test runs are not supported. @@ -222,6 +217,5 @@ The following list of build systems are considered: - Cross-platform builds: supported. - Language support: - C: Supported for GCC, Clang, MSVC and other toolchains. - - Rust: Supported for rustc. - Test integration: supported. Interactive tests are supported starting with Meson 1.5.0 via the `--interactive` flag. diff --git a/Makefile b/Makefile index 8aa489f3b6812f..03e1bd5918d19d 100644 --- a/Makefile +++ b/Makefile @@ -422,9 +422,6 @@ include shared.mak # Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test # programs in oss-fuzz/. # -# Define INCLUDE_LIBGIT_RS if you want `make all` and `make test` to build and -# test the Rust crates in contrib/libgit-sys and contrib/libgit-rs. -# # === Optional library: libintl === # # Define NO_GETTEXT if you don't want Git output to be translated. @@ -493,14 +490,6 @@ include shared.mak # Define LIBPCREDIR=/foo/bar if your PCRE header and library files are # in /foo/bar/include and /foo/bar/lib directories. # -# == Optional Rust support == -# -# Define WITH_RUST if you want to include features and subsystems written in -# Rust into Git. For now, Rust is still an optional feature of the build -# process. With Git 3.0 though, Rust will always be enabled. -# -# Building Rust code requires Cargo. -# # == SHA-1 and SHA-256 defines == # # === SHA-1 backend === @@ -695,13 +684,11 @@ FUZZ_OBJS = FUZZ_PROGRAMS = GIT_OBJS = LIB_OBJS = -LIBGIT_PUB_OBJS = SCALAR_OBJS = OBJECTS = OTHER_PROGRAMS = PROGRAM_OBJS = PROGRAMS = -RUST_SOURCES = EXCLUDED_PROGRAMS = SCRIPT_PERL = SCRIPT_PYTHON = @@ -938,18 +925,6 @@ TEST_SHELL_PATH = $(SHELL_PATH) LIB_FILE = libgit.a -ifdef DEBUG -RUST_TARGET_DIR = target/debug -else -RUST_TARGET_DIR = target/release -endif - -ifeq ($(uname_S),Windows) -RUST_LIB = $(RUST_TARGET_DIR)/gitcore.lib -else -RUST_LIB = $(RUST_TARGET_DIR)/libgitcore.a -endif - GITLIBS = common-main.o $(LIB_FILE) EXTLIBS = @@ -973,15 +948,6 @@ BASIC_LDFLAGS = ARFLAGS = rcs PTHREAD_CFLAGS = -# Rust flags -CARGO_ARGS = -ifndef V -CARGO_ARGS += --quiet -endif -ifndef DEBUG -CARGO_ARGS += --release -endif - # For the 'sparse' target SPARSE_FLAGS ?= -std=gnu99 -D__STDC_NO_VLA__ SP_EXTRA_FLAGS = @@ -1343,9 +1309,7 @@ LIB_OBJS += urlmatch.o LIB_OBJS += usage.o LIB_OBJS += userdiff.o LIB_OBJS += utf8.o -ifndef WITH_RUST LIB_OBJS += varint.o -endif LIB_OBJS += version.o LIB_OBJS += versioncmp.o LIB_OBJS += walker.o @@ -1545,9 +1509,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o -RUST_SOURCES += src/lib.rs -RUST_SOURCES += src/varint.rs - GIT-VERSION-FILE: FORCE @OLD=$$(cat $@ 2>/dev/null || :) && \ $(call version_gen,"$(shell pwd)",GIT-VERSION-FILE.in,$@) && \ @@ -1577,14 +1538,6 @@ endif ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND) ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND) -ifdef WITH_RUST -BASIC_CFLAGS += -DWITH_RUST -GITLIBS += $(RUST_LIB) -ifeq ($(uname_S),Windows) -EXTLIBS += -luserenv -endif -endif - ifdef SANITIZE SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag)) BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE) @@ -2382,12 +2335,6 @@ ifdef CHECK_ASSERTION_SIDE_EFFECTS BASIC_CFLAGS += -DCHECK_ASSERTION_SIDE_EFFECTS endif -ifdef INCLUDE_LIBGIT_RS - # Enable symbol hiding in contrib/libgit-sys/libgitpub.a without making - # us rebuild the whole tree every time we run a Rust build. - BASIC_CFLAGS += -fvisibility=hidden -endif - ifeq ($(TCLTK_PATH),) NO_TCLTK = NoThanks endif @@ -2860,10 +2807,6 @@ OBJECTS += $(UNIT_TEST_OBJS) OBJECTS += $(CLAR_TEST_OBJS) OBJECTS += $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(UNIT_TEST_PROGRAMS)) -ifdef INCLUDE_LIBGIT_RS - OBJECTS += contrib/libgit-sys/public_symbol_export.o -endif - ifndef NO_CURL OBJECTS += http.o http-walker.o remote-curl.o endif @@ -3007,12 +2950,6 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS) $(LIB_FILE): $(LIB_OBJS) $(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^ -$(RUST_LIB): Cargo.toml $(RUST_SOURCES) - $(QUIET_CARGO)cargo build $(CARGO_ARGS) - -.PHONY: rust -rust: $(RUST_LIB) - export DEFAULT_EDITOR DEFAULT_PAGER Documentation/GIT-EXCLUDED-PROGRAMS: FORCE @@ -3868,10 +3805,6 @@ clean: profile-clean coverage-clean cocciclean $(RM) $(htmldocs).tar.gz $(manpages).tar.gz $(MAKE) -C Documentation/ clean $(RM) Documentation/GIT-EXCLUDED-PROGRAMS - $(RM) -r contrib/libgit-sys/target contrib/libgit-rs/target - $(RM) contrib/libgit-sys/partial_symbol_export.o - $(RM) contrib/libgit-sys/hidden_symbol_export.o - $(RM) contrib/libgit-sys/libgitpub.a ifndef NO_PERL $(RM) -r perl/build/ endif @@ -4033,28 +3966,3 @@ $(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT- build-unit-tests: $(UNIT_TEST_PROGS) $(CLAR_TEST_PROG) unit-tests: $(UNIT_TEST_PROGS) $(CLAR_TEST_PROG) t/helper/test-tool$X $(MAKE) -C t/ unit-tests - -.PHONY: libgit-sys libgit-rs -libgit-sys: - $(QUIET)cargo build --manifest-path contrib/libgit-sys/Cargo.toml -libgit-rs: libgit-sys - $(QUIET)cargo build --manifest-path contrib/libgit-rs/Cargo.toml -ifdef INCLUDE_LIBGIT_RS -all:: libgit-rs -endif - -LIBGIT_PUB_OBJS += contrib/libgit-sys/public_symbol_export.o -LIBGIT_PUB_OBJS += libgit.a - -LIBGIT_PARTIAL_EXPORT = contrib/libgit-sys/partial_symbol_export.o - -LIBGIT_HIDDEN_EXPORT = contrib/libgit-sys/hidden_symbol_export.o - -$(LIBGIT_PARTIAL_EXPORT): $(LIBGIT_PUB_OBJS) - $(LD) -r $^ -o $@ - -$(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT) - $(OBJCOPY) --localize-hidden $^ $@ - -contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT) - $(AR) $(ARFLAGS) $@ $^ diff --git a/README.md b/README.md index d87bca1b8c3ebf..249e92974e7f6f 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Git - fast, scalable, distributed revision control system ========================================================= +Git with WD-40 applied. + Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals. diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh index 6ee8216a05e127..7eb1d0dd07fe29 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -137,17 +137,6 @@ StaticAnalysis) sudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \ libexpat-dev gettext make ;; -RustAnalysis) - sudo apt-get -q -y install rustup - rustup default stable - rustup component add clippy rustfmt - - wget -q "$CARGO_MSRV_WHENCE" -O "cargo-msvc.tgz" - sudo mkdir -p "$CUSTOM_PATH" - sudo tar -xf "cargo-msvc.tgz" --strip-components=1 \ - --directory "$CUSTOM_PATH" --wildcards "*/cargo-msrv" - sudo chmod a+x "$CUSTOM_PATH/cargo-msrv" - ;; sparse) sudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \ libexpat-dev gettext zlib1g-dev sparse diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index 8bda62b921920f..d91aa9227c6759 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -1,3 +1,4 @@ + #!/bin/sh # # Build and test Git @@ -8,7 +9,6 @@ case "$jobname" in fedora-breaking-changes-musl|linux-breaking-changes) export WITH_BREAKING_CHANGES=YesPlease - export WITH_RUST=YesPlease MESONFLAGS="$MESONFLAGS -Dbreaking_changes=true" MESONFLAGS="$MESONFLAGS -Drust=enabled" ;; diff --git a/ci/run-rust-checks.sh b/ci/run-rust-checks.sh deleted file mode 100755 index b5ad9e8dc6f71f..00000000000000 --- a/ci/run-rust-checks.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -. ${0%/*}/lib.sh - -set +x - -if ! group "Check Rust formatting" cargo fmt --all --check -then - RET=1 -fi - -if ! group "Check for common Rust mistakes" cargo clippy --all-targets --all-features -- -Dwarnings -then - RET=1 -fi - -if ! group "Check for minimum required Rust version" cargo msrv verify -then - RET=1 -fi - -exit $RET diff --git a/contrib/libgit-rs/Cargo.lock b/contrib/libgit-rs/Cargo.lock deleted file mode 100644 index a30c7c8d33ee30..00000000000000 --- a/contrib/libgit-rs/Cargo.lock +++ /dev/null @@ -1,77 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "cc" -version = "1.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" -dependencies = [ - "shlex", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libgit" -version = "0.1.0" -dependencies = [ - "autocfg", - "libgit-sys", -] - -[[package]] -name = "libgit-sys" -version = "0.1.0" -dependencies = [ - "autocfg", - "libz-sys", - "make-cmd", -] - -[[package]] -name = "libz-sys" -version = "1.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "make-cmd" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3" - -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" diff --git a/contrib/libgit-rs/Cargo.toml b/contrib/libgit-rs/Cargo.toml deleted file mode 100644 index c3289e69db5939..00000000000000 --- a/contrib/libgit-rs/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "libgit" -version = "0.1.0" -edition = "2021" -build = "build.rs" -rust-version = "1.63" # TODO: Once we hit 1.84 or newer, we may want to remove Cargo.lock from - # version control. See https://lore.kernel.org/git/Z47jgK-oMjFRSslr@tapette.crustytoothpaste.net/ - - -[lib] -path = "src/lib.rs" - -[dependencies] -libgit-sys = { version = "0.1.0", path = "../libgit-sys" } - -[build-dependencies] -autocfg = "1.4.0" diff --git a/contrib/libgit-rs/README.md b/contrib/libgit-rs/README.md deleted file mode 100644 index ff945e1ce207e5..00000000000000 --- a/contrib/libgit-rs/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# libgit-rs - -Proof-of-concept Git bindings for Rust. - -```toml -[dependencies] -libgit = "0.1.0" -``` - -## Rust version requirements - -libgit-rs should support Rust versions at least as old as the version included -in Debian stable (currently 1.63). diff --git a/contrib/libgit-rs/build.rs b/contrib/libgit-rs/build.rs deleted file mode 100644 index f8bd01a690b1eb..00000000000000 --- a/contrib/libgit-rs/build.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub fn main() { - let ac = autocfg::new(); - ac.emit_has_path("std::ffi::c_char"); -} diff --git a/contrib/libgit-rs/src/config.rs b/contrib/libgit-rs/src/config.rs deleted file mode 100644 index 6bf04845c8f01b..00000000000000 --- a/contrib/libgit-rs/src/config.rs +++ /dev/null @@ -1,106 +0,0 @@ -use std::ffi::{c_void, CStr, CString}; -use std::path::Path; - -#[cfg(has_std__ffi__c_char)] -use std::ffi::{c_char, c_int}; - -#[cfg(not(has_std__ffi__c_char))] -#[allow(non_camel_case_types)] -type c_char = i8; - -#[cfg(not(has_std__ffi__c_char))] -#[allow(non_camel_case_types)] -type c_int = i32; - -use libgit_sys::*; - -/// A ConfigSet is an in-memory cache for config-like files such as `.gitmodules` or `.gitconfig`. -/// It does not support all config directives; notably, it will not process `include` or -/// `includeIf` directives (but it will store them so that callers can choose whether and how to -/// handle them). -pub struct ConfigSet(*mut libgit_config_set); -impl ConfigSet { - /// Allocate a new ConfigSet - pub fn new() -> Self { - unsafe { ConfigSet(libgit_configset_alloc()) } - } - - /// Load the given files into the ConfigSet; conflicting directives in later files will - /// override those given in earlier files. - pub fn add_files(&mut self, files: &[&Path]) { - for file in files { - let pstr = file.to_str().expect("Invalid UTF-8"); - let rs = CString::new(pstr).expect("Couldn't convert to CString"); - unsafe { - libgit_configset_add_file(self.0, rs.as_ptr()); - } - } - } - - /// Load the value for the given key and attempt to parse it as an i32. Dies with a fatal error - /// if the value cannot be parsed. Returns None if the key is not present. - pub fn get_int(&mut self, key: &str) -> Option { - let key = CString::new(key).expect("Couldn't convert to CString"); - let mut val: c_int = 0; - unsafe { - if libgit_configset_get_int(self.0, key.as_ptr(), &mut val as *mut c_int) != 0 { - return None; - } - } - - Some(val.into()) - } - - /// Clones the value for the given key. Dies with a fatal error if the value cannot be - /// converted to a String. Returns None if the key is not present. - pub fn get_string(&mut self, key: &str) -> Option { - let key = CString::new(key).expect("Couldn't convert key to CString"); - let mut val: *mut c_char = std::ptr::null_mut(); - unsafe { - if libgit_configset_get_string(self.0, key.as_ptr(), &mut val as *mut *mut c_char) != 0 - { - return None; - } - let borrowed_str = CStr::from_ptr(val); - let owned_str = - String::from(borrowed_str.to_str().expect("Couldn't convert val to str")); - free(val as *mut c_void); // Free the xstrdup()ed pointer from the C side - Some(owned_str) - } - } -} - -impl Default for ConfigSet { - fn default() -> Self { - Self::new() - } -} - -impl Drop for ConfigSet { - fn drop(&mut self) { - unsafe { - libgit_configset_free(self.0); - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn load_configs_via_configset() { - let mut cs = ConfigSet::new(); - cs.add_files(&[ - Path::new("testdata/config1"), - Path::new("testdata/config2"), - Path::new("testdata/config3"), - ]); - // ConfigSet retrieves correct value - assert_eq!(cs.get_int("trace2.eventTarget"), Some(1)); - // ConfigSet respects last config value set - assert_eq!(cs.get_int("trace2.eventNesting"), Some(3)); - // ConfigSet returns None for missing key - assert_eq!(cs.get_string("foo.bar"), None); - } -} diff --git a/contrib/libgit-rs/src/lib.rs b/contrib/libgit-rs/src/lib.rs deleted file mode 100644 index ef68c36943d46d..00000000000000 --- a/contrib/libgit-rs/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod config; diff --git a/contrib/libgit-rs/testdata/config1 b/contrib/libgit-rs/testdata/config1 deleted file mode 100644 index 4e9a9d25d1ffe8..00000000000000 --- a/contrib/libgit-rs/testdata/config1 +++ /dev/null @@ -1,2 +0,0 @@ -[trace2] - eventNesting = 1 diff --git a/contrib/libgit-rs/testdata/config2 b/contrib/libgit-rs/testdata/config2 deleted file mode 100644 index b8d1eca4235f20..00000000000000 --- a/contrib/libgit-rs/testdata/config2 +++ /dev/null @@ -1,2 +0,0 @@ -[trace2] - eventTarget = 1 diff --git a/contrib/libgit-rs/testdata/config3 b/contrib/libgit-rs/testdata/config3 deleted file mode 100644 index ca7b9a7c38039c..00000000000000 --- a/contrib/libgit-rs/testdata/config3 +++ /dev/null @@ -1,2 +0,0 @@ -[trace2] - eventNesting = 3 diff --git a/contrib/libgit-sys/Cargo.lock b/contrib/libgit-sys/Cargo.lock deleted file mode 100644 index 427a4c66b7e2cd..00000000000000 --- a/contrib/libgit-sys/Cargo.lock +++ /dev/null @@ -1,69 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "cc" -version = "1.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" -dependencies = [ - "shlex", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libgit-sys" -version = "0.1.0" -dependencies = [ - "autocfg", - "libz-sys", - "make-cmd", -] - -[[package]] -name = "libz-sys" -version = "1.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "make-cmd" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3" - -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" diff --git a/contrib/libgit-sys/Cargo.toml b/contrib/libgit-sys/Cargo.toml deleted file mode 100644 index e0623022c35f01..00000000000000 --- a/contrib/libgit-sys/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "libgit-sys" -version = "0.1.0" -edition = "2021" -build = "build.rs" -links = "gitpub" -rust-version = "1.63" # TODO: Once we hit 1.84 or newer, we may want to remove Cargo.lock from - # version control. See https://lore.kernel.org/git/Z47jgK-oMjFRSslr@tapette.crustytoothpaste.net/ -description = "Native bindings to a portion of libgit" - -[lib] -path = "src/lib.rs" - -[dependencies] -libz-sys = "1.1.19" - -[build-dependencies] -autocfg = "1.4.0" -make-cmd = "0.1.0" diff --git a/contrib/libgit-sys/README.md b/contrib/libgit-sys/README.md deleted file mode 100644 index c061cfcaf58f4d..00000000000000 --- a/contrib/libgit-sys/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# libgit-sys - -A small proof-of-concept crate showing how to provide a Rust FFI to Git -internals. diff --git a/contrib/libgit-sys/build.rs b/contrib/libgit-sys/build.rs deleted file mode 100644 index 3ffd80ad91075c..00000000000000 --- a/contrib/libgit-sys/build.rs +++ /dev/null @@ -1,35 +0,0 @@ -use std::env; -use std::path::PathBuf; - -pub fn main() -> std::io::Result<()> { - let ac = autocfg::new(); - ac.emit_has_path("std::ffi::c_char"); - - let crate_root = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); - let git_root = crate_root.join("../.."); - let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - - let make_output = make_cmd::gnu_make() - .env("DEVELOPER", "1") - .env_remove("PROFILE") - .current_dir(git_root.clone()) - .args([ - "INCLUDE_LIBGIT_RS=YesPlease", - "contrib/libgit-sys/libgitpub.a", - ]) - .output() - .expect("Make failed to run"); - if !make_output.status.success() { - panic!( - "Make failed:\n stdout = {}\n stderr = {}\n", - String::from_utf8(make_output.stdout).unwrap(), - String::from_utf8(make_output.stderr).unwrap() - ); - } - std::fs::copy(crate_root.join("libgitpub.a"), dst.join("libgitpub.a"))?; - println!("cargo:rustc-link-search=native={}", dst.display()); - println!("cargo:rustc-link-lib=gitpub"); - println!("cargo:rerun-if-changed={}", git_root.display()); - - Ok(()) -} diff --git a/contrib/libgit-sys/public_symbol_export.c b/contrib/libgit-sys/public_symbol_export.c deleted file mode 100644 index dfbb2571152d6e..00000000000000 --- a/contrib/libgit-sys/public_symbol_export.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Shim to publicly export Git symbols. These must be renamed so that the - * original symbols can be hidden. Renaming these with a "libgit_" prefix also - * avoids conflicts with other libraries such as libgit2. - */ - -#include "git-compat-util.h" -#include "config.h" -#include "contrib/libgit-sys/public_symbol_export.h" -#include "version.h" - -#pragma GCC visibility push(default) - -struct libgit_config_set { - struct config_set cs; -}; - -struct libgit_config_set *libgit_configset_alloc(void) -{ - struct libgit_config_set *cs = - xmalloc(sizeof(struct libgit_config_set)); - git_configset_init(&cs->cs); - return cs; -} - -void libgit_configset_free(struct libgit_config_set *cs) -{ - git_configset_clear(&cs->cs); - free(cs); -} - -int libgit_configset_add_file(struct libgit_config_set *cs, const char *filename) -{ - return git_configset_add_file(&cs->cs, filename); -} - -int libgit_configset_get_int(struct libgit_config_set *cs, const char *key, - int *dest) -{ - return git_configset_get_int(&cs->cs, key, dest); -} - -int libgit_configset_get_string(struct libgit_config_set *cs, const char *key, - char **dest) -{ - return git_configset_get_string(&cs->cs, key, dest); -} - -const char *libgit_user_agent(void) -{ - return git_user_agent(); -} - -const char *libgit_user_agent_sanitized(void) -{ - return git_user_agent_sanitized(); -} - -#pragma GCC visibility pop diff --git a/contrib/libgit-sys/public_symbol_export.h b/contrib/libgit-sys/public_symbol_export.h deleted file mode 100644 index 701db92d53461d..00000000000000 --- a/contrib/libgit-sys/public_symbol_export.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef PUBLIC_SYMBOL_EXPORT_H -#define PUBLIC_SYMBOL_EXPORT_H - -struct libgit_config_set *libgit_configset_alloc(void); - -void libgit_configset_free(struct libgit_config_set *cs); - -int libgit_configset_add_file(struct libgit_config_set *cs, const char *filename); - -int libgit_configset_get_int(struct libgit_config_set *cs, const char *key, int *dest); - -int libgit_configset_get_string(struct libgit_config_set *cs, const char *key, char **dest); - -const char *libgit_user_agent(void); - -const char *libgit_user_agent_sanitized(void); - -#endif /* PUBLIC_SYMBOL_EXPORT_H */ diff --git a/contrib/libgit-sys/src/lib.rs b/contrib/libgit-sys/src/lib.rs deleted file mode 100644 index 4bfc65045026cf..00000000000000 --- a/contrib/libgit-sys/src/lib.rs +++ /dev/null @@ -1,79 +0,0 @@ -use std::ffi::c_void; - -#[cfg(has_std__ffi__c_char)] -use std::ffi::{c_char, c_int}; - -#[cfg(not(has_std__ffi__c_char))] -#[allow(non_camel_case_types)] -pub type c_char = i8; - -#[cfg(not(has_std__ffi__c_char))] -#[allow(non_camel_case_types)] -pub type c_int = i32; - -extern crate libz_sys; - -#[allow(non_camel_case_types)] -#[repr(C)] -pub struct libgit_config_set { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, -} - -extern "C" { - pub fn free(ptr: *mut c_void); - - pub fn libgit_user_agent() -> *const c_char; - pub fn libgit_user_agent_sanitized() -> *const c_char; - - pub fn libgit_configset_alloc() -> *mut libgit_config_set; - pub fn libgit_configset_free(cs: *mut libgit_config_set); - - pub fn libgit_configset_add_file(cs: *mut libgit_config_set, filename: *const c_char) -> c_int; - - pub fn libgit_configset_get_int( - cs: *mut libgit_config_set, - key: *const c_char, - int: *mut c_int, - ) -> c_int; - - pub fn libgit_configset_get_string( - cs: *mut libgit_config_set, - key: *const c_char, - dest: *mut *mut c_char, - ) -> c_int; - -} - -#[cfg(test)] -mod tests { - use std::ffi::CStr; - - use super::*; - - #[test] - fn user_agent_starts_with_git() { - let c_str = unsafe { CStr::from_ptr(libgit_user_agent()) }; - let agent = c_str - .to_str() - .expect("User agent contains invalid UTF-8 data"); - assert!( - agent.starts_with("git/"), - r#"Expected user agent to start with "git/", got: {}"#, - agent - ); - } - - #[test] - fn sanitized_user_agent_starts_with_git() { - let c_str = unsafe { CStr::from_ptr(libgit_user_agent_sanitized()) }; - let agent = c_str - .to_str() - .expect("Sanitized user agent contains invalid UTF-8 data"); - assert!( - agent.starts_with("git/"), - r#"Expected user agent to start with "git/", got: {}"#, - agent - ); - } -} diff --git a/help.c b/help.c index 3c36d9c218f824..9a2b27c8343791 100644 --- a/help.c +++ b/help.c @@ -1,3 +1,4 @@ + #define USE_THE_REPOSITORY_VARIABLE #define DISABLE_SIGN_COMPARE_WARNINGS @@ -791,12 +792,6 @@ void get_version_info(struct strbuf *buf, int show_build_options) strbuf_addf(buf, "shell-path: %s\n", SHELL_PATH); /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */ -#if defined WITH_RUST - strbuf_addstr(buf, "rust: enabled\n"); -#else - strbuf_addstr(buf, "rust: disabled\n"); -#endif - if (fsmonitor_ipc__is_supported()) strbuf_addstr(buf, "feature: fsmonitor--daemon\n"); #if !defined NO_GETTEXT diff --git a/meson.build b/meson.build index dd52efd1c87574..c08cade463c467 100644 --- a/meson.build +++ b/meson.build @@ -1720,20 +1720,9 @@ version_def_h = custom_target( ) libgit_sources += version_def_h -cargo = find_program('cargo', dirs: program_path, native: true, required: get_option('rust')) -rust_option = get_option('rust').disable_auto_if(not cargo.found()) -if rust_option.allowed() - subdir('src') - libgit_c_args += '-DWITH_RUST' - - if host_machine.system() == 'windows' - libgit_dependencies += compiler.find_library('userenv') - endif -else - libgit_sources += [ +libgit_sources += [ 'varint.c', - ] -endif +] libgit = declare_dependency( link_with: static_library('git', diff --git a/src/cargo-meson.sh b/src/cargo-meson.sh deleted file mode 100755 index 38728a371137f9..00000000000000 --- a/src/cargo-meson.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -if test "$#" -lt 2 -then - exit 1 -fi - -SOURCE_DIR="$1" -BUILD_DIR="$2" -BUILD_TYPE=debug - -shift 2 - -for arg -do - case "$arg" in - --release) - BUILD_TYPE=release;; - esac -done - -cargo build --lib --quiet --manifest-path="$SOURCE_DIR/Cargo.toml" --target-dir="$BUILD_DIR" "$@" -RET=$? -if test $RET -ne 0 -then - exit $RET -fi - -case "$(cargo -vV | sed -n 's/^host: \(.*\)$/\1/p')" in - *-windows-*) - LIBNAME=gitcore.lib;; - *) - LIBNAME=libgitcore.a;; -esac - -if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1 -then - cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" -fi diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 9da70d8b57d5f6..00000000000000 --- a/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod varint; diff --git a/src/meson.build b/src/meson.build deleted file mode 100644 index 25b9ad5a1479c0..00000000000000 --- a/src/meson.build +++ /dev/null @@ -1,41 +0,0 @@ -libgit_rs_sources = [ - 'lib.rs', - 'varint.rs', -] - -# Unfortunately we must use a wrapper command to move the output file into the -# current build directory. This can fixed once `cargo build --artifact-dir` -# stabilizes. See https://github.com/rust-lang/cargo/issues/6790 for that -# effort. -cargo_command = [ - shell, - meson.current_source_dir() / 'cargo-meson.sh', - meson.project_source_root(), - meson.current_build_dir(), -] -if get_option('buildtype') == 'release' - cargo_command += '--release' -endif - -libgit_rs = custom_target('git_rs', - input: libgit_rs_sources + [ - meson.project_source_root() / 'Cargo.toml', - ], - output: 'libgitcore.a', - command: cargo_command, -) -libgit_dependencies += declare_dependency(link_with: libgit_rs) - -if get_option('tests') - test('rust', cargo, - args: [ - 'test', - '--manifest-path', - meson.project_source_root() / 'Cargo.toml', - '--target-dir', - meson.current_build_dir() / 'target', - ], - timeout: 0, - protocol: 'rust', - ) -endif diff --git a/src/varint.rs b/src/varint.rs deleted file mode 100644 index 06492dfc5eaeef..00000000000000 --- a/src/varint.rs +++ /dev/null @@ -1,107 +0,0 @@ -/// Decode the variable-length integer stored in `bufp` and return the decoded value. -/// -/// Returns 0 in case the decoded integer would overflow u64::MAX. -/// -/// # Safety -/// -/// The buffer must be NUL-terminated to ensure safety. -#[no_mangle] -pub unsafe extern "C" fn decode_varint(bufp: *mut *const u8) -> u64 { - let mut buf = *bufp; - let mut c = *buf; - let mut val = u64::from(c & 127); - - buf = buf.add(1); - - while (c & 128) != 0 { - val = val.wrapping_add(1); - if val == 0 || val.leading_zeros() < 7 { - return 0; // overflow - } - - c = *buf; - buf = buf.add(1); - - val = (val << 7) + u64::from(c & 127); - } - - *bufp = buf; - val -} - -/// Encode `value` into `buf` as a variable-length integer unless `buf` is null. -/// -/// Returns the number of bytes written, or, if `buf` is null, the number of bytes that would be -/// written to encode the integer. -/// -/// # Safety -/// -/// `buf` must either be null or point to at least 16 bytes of memory. -#[no_mangle] -pub unsafe extern "C" fn encode_varint(value: u64, buf: *mut u8) -> u8 { - let mut varint: [u8; 16] = [0; 16]; - let mut pos = varint.len() - 1; - - varint[pos] = (value & 127) as u8; - - let mut value = value >> 7; - while value != 0 { - pos -= 1; - value -= 1; - varint[pos] = 128 | (value & 127) as u8; - value >>= 7; - } - - if !buf.is_null() { - std::ptr::copy_nonoverlapping(varint.as_ptr().add(pos), buf, varint.len() - pos); - } - - (varint.len() - pos) as u8 -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_decode_varint() { - unsafe { - assert_eq!(decode_varint(&mut [0x00].as_slice().as_ptr()), 0); - assert_eq!(decode_varint(&mut [0x01].as_slice().as_ptr()), 1); - assert_eq!(decode_varint(&mut [0x7f].as_slice().as_ptr()), 127); - assert_eq!(decode_varint(&mut [0x80, 0x00].as_slice().as_ptr()), 128); - assert_eq!(decode_varint(&mut [0x80, 0x01].as_slice().as_ptr()), 129); - assert_eq!(decode_varint(&mut [0x80, 0x7f].as_slice().as_ptr()), 255); - - // Overflows are expected to return 0. - assert_eq!(decode_varint(&mut [0x88; 16].as_slice().as_ptr()), 0); - } - } - - #[test] - fn test_encode_varint() { - unsafe { - let mut varint: [u8; 16] = [0; 16]; - - assert_eq!(encode_varint(0, std::ptr::null_mut()), 1); - - assert_eq!(encode_varint(0, varint.as_mut_slice().as_mut_ptr()), 1); - assert_eq!(varint, [0; 16]); - - assert_eq!(encode_varint(10, varint.as_mut_slice().as_mut_ptr()), 1); - assert_eq!(varint, [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - - assert_eq!(encode_varint(127, varint.as_mut_slice().as_mut_ptr()), 1); - assert_eq!(varint, [127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - - assert_eq!(encode_varint(128, varint.as_mut_slice().as_mut_ptr()), 2); - assert_eq!(varint, [128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - - assert_eq!(encode_varint(129, varint.as_mut_slice().as_mut_ptr()), 2); - assert_eq!(varint, [128, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - - assert_eq!(encode_varint(255, varint.as_mut_slice().as_mut_ptr()), 2); - assert_eq!(varint, [128, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - } - } -} diff --git a/t/Makefile b/t/Makefile index ab8a5b54aa6ce0..e9cc9f28e3a87c 100644 --- a/t/Makefile +++ b/t/Makefile @@ -192,6 +192,3 @@ libgit-sys-test: $(QUIET)cargo test --manifest-path ../contrib/libgit-sys/Cargo.toml libgit-rs-test: libgit-sys-test $(QUIET)cargo test --manifest-path ../contrib/libgit-rs/Cargo.toml -ifdef INCLUDE_LIBGIT_RS -all:: libgit-rs-test -endif From 50d93eb373cb0c81f63472c3a05e235fe85ab102 Mon Sep 17 00:00:00 2001 From: Herman Semenoff Date: Tue, 10 Feb 2026 04:36:41 +0300 Subject: [PATCH 2/2] mv: fix memleak when safe_create_leading_directories alloc failed `dst_dup` variable, allocated with `xstrdup()`, is not always freed. If safe_create_leading_directories() fails, the allocated memory is leaked. Git codebase shows that it is recommended to always check result safe_create_leading_directories() function. --- builtin/mv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builtin/mv.c b/builtin/mv.c index d43925097b420f..3119be77ae4c68 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -613,7 +613,10 @@ int cmd_mv(int argc, */ char *dst_dup = xstrdup(dst); string_list_append(&dirty_paths, dst); - safe_create_leading_directories(the_repository, dst_dup); + if (safe_create_leading_directories(the_repository, dst_dup)) { + free(dst_dup); + die(_("failed to create leading directories of '%s'"), dst); + } FREE_AND_NULL(dst_dup); rename(src, dst); }