Local workflow, smart-HTTP clone/fetch/push and public HTTPS clone/fetch match native git in stdout and exit codes. Only WASI imports (wasi:http, exit-with-code).
2.6 KiB
Git for WASI 0.2
This crate adapts the v2 Git plugin's local operations and HTTP transport.
It uses gix 0.90 and the patches in vendor/PATCHES.md.
It does not use the plugin SDK, RPC dispatch, the vault, or SSH.
The host supplies credentials through standard wasi:http.
Build
Run the build from userland/ to include the workspace's cwd constructor:
CARGO_TARGET_DIR=/tmp/p1-git/target nix develop .. -c cargo build -p git --release
The following commands run from the repository root.
Native/WASI comparison and import check
nix develop -c nu userland/git/test.nu /tmp/p1-git/target/wasm32-wasip2/release/git.wasm
The script checks that the component imports only WASI interfaces.
It creates separate native and WASI repositories under /tmp/p1-git/.
It fixes both identities and timestamps.
It compares stdout and exit codes without filtering command output.
Initialization and worktree listings compare exit codes only because their paths differ.
The script retains its fixtures for inspection.
wasmtime run needs -S http, including for local operations.
It also needs -S cli-exit-with-code=y to preserve Git's numeric exit codes.
The component uses WASI's exit-with-code, not a custom host import.
The world host must enable that optional WASI function.
The tests pass explicit -C paths.
Local smart-HTTP test
Build the native fixture server:
CARGO_TARGET_DIR=/tmp/p1-git/server-target nix develop -c cargo build --manifest-path userland/git/tests/http-server/Cargo.toml
The server wraps native git http-backend without TLS.
It accepts a repository directory and a readiness file.
The readiness file receives the bound localhost port.
Start the server in a separate terminal:
mkdir -p /tmp/p1-git/http-repos
/tmp/p1-git/server-target/debug/git-test-http-server /tmp/p1-git/http-repos /tmp/p1-git/http-port
Use that port in the integration test:
nix develop -c nu userland/git/http-test.nu /tmp/p1-git/target/wasm32-wasip2/release/git.wasm /tmp/p1-git/http-repos http://127.0.0.1:PORT/repo.git
Use a fresh repository name for each test run. The script checks anonymous clone, fetch, and push through WASI. It checks the resulting object IDs with native Git.
Anonymous HTTPS test
The host handles TLS, not the guest. Test HTTPS separately against the small public Hello-World repository:
nix develop -c nu userland/git/public-https-test.nu /tmp/p1-git/target/wasm32-wasip2/release/git.wasm
This test clones the repository and fetches it again. It does not need credentials. HTTPS push requires the host's later credential injection.