userland/git: git-compatible CLI on v2's gix code (T10)

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).
This commit is contained in:
2026-11-06 16:07:57 +00:00
parent 0fae0f9b10
commit 4b27e9afd5
204 changed files with 37736 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
//! Parse Git CLI arguments and return Git-compatible usage and operation exit codes.
use clap::{Parser, error::ErrorKind};
fn main() {
let cli = match git::Cli::try_parse() {
Ok(cli) => cli,
Err(error) => {
let code = if !error.use_stderr() {
0
} else {
match error.kind() {
ErrorKind::InvalidSubcommand | ErrorKind::MissingSubcommand => 1,
_ => 129,
}
};
let _ = error.print();
exit(code);
}
};
let code = match git::run(cli) {
Ok(code) => code,
Err(error) => {
eprintln!("fatal: {error}");
128
}
};
exit(code);
}
fn exit(code: i32) -> ! {
#[cfg(target_os = "wasi")]
{
use std::io::Write;
let _ = std::io::stdout().flush();
let _ = std::io::stderr().flush();
wasi::cli::exit::exit_with_code(code as u8);
unreachable!("WASI exit returned");
}
#[cfg(not(target_os = "wasi"))]
std::process::exit(code)
}