git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] Move rust gitcore crate to a different subdirectory

From
Mike Hommey <mh@glandium.org>
Date
Feb 9, 2026, 22:48 UTC
Message-ID
<20260209224847.1416916-1-mh@glandium.org>
In-Reply-To
<20260204232208.1615320-1-mh@glandium.org>

While `src/` is the default directory convention for Rust projects, it is too generic in the context of a multi-language project that is barely starting to (optionally) use Rust code.

Additionally, having `Cargo.toml` at the top-level of the repository implies that one can run `cargo build` directly, but this doesn't produce anything useful on its own.

Moving all Rust-specific files into a dedicated `rust/` subdirectory makes things clearer.

Signed-off-by: Mike Hommey <mh@glandium.org>
---
 .gitignore                    |  2 ++
 Makefile                      | 12 ++++++------
 meson.build                   |  2 +-
 Cargo.toml => rust/Cargo.toml |  0
 {src => rust}/cargo-meson.sh  |  0
 {src => rust}/meson.build     |  6 +++---
 {src => rust/src}/lib.rs      |  0
 {src => rust/src}/varint.rs   |  0
 8 files changed, 12 insertions(+), 10 deletions(-)
 rename Cargo.toml => rust/Cargo.toml (100%)
 rename {src => rust}/cargo-meson.sh (100%)
 rename {src => rust}/meson.build (87%)
 rename {src => rust/src}/lib.rs (100%)
 rename {src => rust/src}/varint.rs (100%)
diff --git a/.gitignore b/.gitignore
index 78a45cb5be..c7453b6fb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -258,3 +258,5 @@ Release/
 /contrib/buildsystems/out
 /contrib/libgit-rs/target
 /contrib/libgit-sys/target
+/rust/target
+/rust/Cargo.lock
diff --git a/Makefile b/Makefile
index 8aa489f3b6..b60af704ed 100644
--- a/Makefile
+++ b/Makefile
@@ -939,9 +939,9 @@ TEST_SHELL_PATH = $(SHELL_PATH)
 LIB_FILE = libgit.a
 
 ifdef DEBUG
-RUST_TARGET_DIR = target/debug
+RUST_TARGET_DIR = rust/target/debug
 else
-RUST_TARGET_DIR = target/release
+RUST_TARGET_DIR = rust/target/release
 endif
 
 ifeq ($(uname_S),Windows)
@@ -1545,8 +1545,8 @@ 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
+RUST_SOURCES += rust/src/lib.rs
+RUST_SOURCES += rust/src/varint.rs
 
 GIT-VERSION-FILE: FORCE
 	@OLD=$$(cat $@ 2>/dev/null || :) && \
@@ -3007,8 +3007,8 @@ 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)
+$(RUST_LIB): rust/Cargo.toml $(RUST_SOURCES)
+	$(QUIET_CARGO)cargo build --manifest-path rust/Cargo.toml $(CARGO_ARGS)
 
 .PHONY: rust
 rust: $(RUST_LIB)
diff --git a/meson.build b/meson.build
index dd52efd1c8..3a92936241 100644
--- a/meson.build
+++ b/meson.build
@@ -1723,7 +1723,7 @@ 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')
+  subdir('rust/src')
   libgit_c_args += '-DWITH_RUST'
 
   if host_machine.system() == 'windows'
diff --git a/Cargo.toml b/rust/Cargo.toml
similarity index 100%
rename from Cargo.toml
rename to rust/Cargo.toml
diff --git a/src/cargo-meson.sh b/rust/cargo-meson.sh
similarity index 100%
rename from src/cargo-meson.sh
rename to rust/cargo-meson.sh
diff --git a/src/meson.build b/rust/meson.build
similarity index 87%
rename from src/meson.build
rename to rust/meson.build
index 25b9ad5a14..9490272521 100644
--- a/src/meson.build
+++ b/rust/meson.build
@@ -10,7 +10,7 @@ libgit_rs_sources = [
 cargo_command = [
   shell,
   meson.current_source_dir() / 'cargo-meson.sh',
-  meson.project_source_root(),
+  meson.current_source_dir(),
   meson.current_build_dir(),
 ]
 if get_option('buildtype') == 'release'
@@ -19,7 +19,7 @@ endif
 
 libgit_rs = custom_target('git_rs',
   input: libgit_rs_sources + [
-    meson.project_source_root() / 'Cargo.toml',
+    meson.current_source_dir() / 'Cargo.toml',
   ],
   output: 'libgitcore.a',
   command: cargo_command,
@@ -31,7 +31,7 @@ if get_option('tests')
     args: [
       'test',
       '--manifest-path',
-      meson.project_source_root() / 'Cargo.toml',
+      meson.current_source_dir() / 'Cargo.toml',
       '--target-dir',
       meson.current_build_dir() / 'target',
     ],
diff --git a/src/lib.rs b/rust/src/lib.rs
similarity index 100%
rename from src/lib.rs
rename to rust/src/lib.rs
diff --git a/src/varint.rs b/rust/src/varint.rs
similarity index 100%
rename from src/varint.rs
rename to rust/src/varint.rs
-- 
2.52.0
Previous: Mike HommeyNext: Mike Hommey
Message 6 of 18 in “Move rust gitcore crate to a different subdirectory”
  1. Move rust gitcore crate to a different subdirectoryMike Hommey, Feb 4, 2026
  2. brian m. carlsonFeb 5, 2026
  3. Mike HommeyFeb 5, 2026
  4. brian m. carlsonFeb 5, 2026
  5. Mike HommeyFeb 5, 2026
  6. Move rust gitcore crate to a different subdirectoryMike Hommey, Feb 9, 2026
  7. Move rust gitcore crate to a different subdirectoryMike Hommey, Sep 9, 2026
  8. Junio C HamanoSep 9, 2026
  9. Mike HommeySep 10, 2026
  10. brian m. carlsonSep 9, 2026
  11. Mike HommeySep 10, 2026
  12. Tuomas AholaSep 10, 2026
  13. Junio C HamanoSep 10, 2026
  14. Move rust gitcore crate to a different subdirectoryMike Hommey, Sep 10, 2026
  15. Junio C HamanoSep 10, 2026
  16. move rust gitcore crate to a different subdirectoryMike Hommey, Sep 17, 2026
  17. Junio C HamanoSep 18, 2026
  18. Mike HommeySep 18, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.