]> Kevux Git Server - rit/commitdiff
Update: Remove Rust code. development
authorKevin Day <Kevin@kevux.org>
Thu, 5 Feb 2026 01:49:08 +0000 (19:49 -0600)
committerKevin Day <Kevin@kevux.org>
Thu, 5 Feb 2026 01:57:39 +0000 (19:57 -0600)
The original upstream Git is moving to Rust.
> 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.

And:
> In Git 3.0, the build options will be removed and support for Rust is mandatory.

This means that is is now time to fork Git into this project that is not being called Rit as a means for distinction.

This is not something I really wanted to do, but I suppose sometimes one must do something experimental.

The `userdif.c` is not changed because Rust is a valid programming language and the `git diff`, or now the `rit diff`, should still support it.
The commit hash below describes the commit with the files that should not be changed.

see: https://git-scm.com/docs/BreakingChanges
see: https://lore.kernel.org/lkml/xmqq4inz13e3.fsf@gitster.g/
see: https://github.com/git/git/commit/d74e78602e3d562f5db64d553d4be21c201ef7b3

21 files changed:
Makefile
contrib/libgit-rs/Cargo.lock [deleted file]
contrib/libgit-rs/Cargo.toml [deleted file]
contrib/libgit-rs/README.md [deleted file]
contrib/libgit-rs/build.rs [deleted file]
contrib/libgit-rs/src/config.rs [deleted file]
contrib/libgit-rs/src/lib.rs [deleted file]
contrib/libgit-rs/testdata/config1 [deleted file]
contrib/libgit-rs/testdata/config2 [deleted file]
contrib/libgit-rs/testdata/config3 [deleted file]
contrib/libgit-sys/Cargo.lock [deleted file]
contrib/libgit-sys/Cargo.toml [deleted file]
contrib/libgit-sys/README.md [deleted file]
contrib/libgit-sys/build.rs [deleted file]
contrib/libgit-sys/public_symbol_export.c [deleted file]
contrib/libgit-sys/public_symbol_export.h [deleted file]
contrib/libgit-sys/src/lib.rs [deleted file]
src/lib.rs [deleted file]
src/meson.build
src/varint.rs [deleted file]
t/Makefile

index 8aa489f3b6812f0848772e790887121e837dbe30..3c2dd99547fc5f30e6da42fa47c801b85abbe4b7 100644 (file)
--- 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.
@@ -701,7 +698,6 @@ OBJECTS =
 OTHER_PROGRAMS =
 PROGRAM_OBJS =
 PROGRAMS =
-RUST_SOURCES =
 EXCLUDED_PROGRAMS =
 SCRIPT_PERL =
 SCRIPT_PYTHON =
@@ -938,18 +934,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 =
 
@@ -1545,9 +1529,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,$@) && \
@@ -2382,12 +2363,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 +2835,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
@@ -3868,10 +3839,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
@@ -4034,27 +4001,10 @@ 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/contrib/libgit-rs/Cargo.lock b/contrib/libgit-rs/Cargo.lock
deleted file mode 100644 (file)
index a30c7c8..0000000
+++ /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 (file)
index c3289e6..0000000
+++ /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 (file)
index ff945e1..0000000
+++ /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 (file)
index f8bd01a..0000000
+++ /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 (file)
index 6bf0484..0000000
+++ /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<i32> {
-        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<String> {
-        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 (file)
index ef68c36..0000000
+++ /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 (file)
index 4e9a9d2..0000000
+++ /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 (file)
index b8d1eca..0000000
+++ /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 (file)
index ca7b9a7..0000000
+++ /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 (file)
index 427a4c6..0000000
+++ /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 (file)
index e062302..0000000
+++ /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 (file)
index c061cfc..0000000
+++ /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 (file)
index 3ffd80a..0000000
+++ /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 (file)
index dfbb257..0000000
+++ /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 (file)
index 701db92..0000000
+++ /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 (file)
index 4bfc650..0000000
+++ /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/src/lib.rs b/src/lib.rs
deleted file mode 100644 (file)
index 9da70d8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-pub mod varint;
index 25b9ad5a1479c0e440d4e650992a2ed936a3401c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -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 (file)
index 06492df..0000000
+++ /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]);
-        }
-    }
-}
index ab8a5b54aa6ce08bf3b85a9ee016b3dbec0688cf..95a9fdcefb345dc535ac27f176dbac42a874eb2a 100644 (file)
@@ -186,12 +186,3 @@ perf:
 
 .PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
        check-chainlint clean-chainlint test-chainlint $(UNIT_TESTS)
-
-.PHONY: libgit-sys-test libgit-rs-test
-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