Expand description
Captured read-only real-Git queries over raw bytes. What: Run a read-only real-Git query and capture its output as raw bytes. Why: Repository facts (top level, Git directory) come from Git itself, and the paths it prints need not be UTF-8.
In TS you’d write (pseudocode):
// const { stdout } = await spawn(gitPath, ['rev-parse', '--git-dir'], { stdout: 'pipe' });Structs§
- Metadata
Output - What:
What one metadata query produced.
Vec<u8>is an owned byte list (u8is one byte); siblingStringwould require UTF-8. Why: Git prints paths as raw bytes, and a failed query is an ordinary answer (“not a repository”), not an error.
Functions§
- path_
from_ git_ bytes - What:
Turn path bytes printed by Git into a path,
without decoding on Unix.
Option<PathBuf>is “an owned path or nothing”.#[cfg(unix)]and#[cfg(not(unix))]each compile one of the two inner blocks. Why: Unix paths are arbitrary bytes and must round-trip exactly; other systems can only build a path from valid UTF-8. An empty value is never a path anywhere. - run_
metadata_ git - What:
Run real Git with captured output and no standard input.
std::io::Result<T>isResult<T, std::io::Error>. Why: A query must never consume the caller’s stdin (which belongs to the forwarded command) or write to the caller’s streams. - strip_
git_ line - What:
Remove exactly one final line break (
\nor\r\n) from Git output.&[u8]borrows bytes; the result borrows a shorter view of the same bytes. Why: Git terminates each printed value with one line break; anything before it, including other line breaks, is part of the value.