Skip to main content

Module git_metadata

Module git_metadata 

Source
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§

MetadataOutput
What: What one metadata query produced. Vec<u8> is an owned byte list (u8 is one byte); sibling String would 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> is Result<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 (\n or \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.