Skip to main content

path_from_git_bytes

Function path_from_git_bytes 

Source
pub fn path_from_git_bytes(bytes: &[u8]) -> Option<PathBuf>
Expand description

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.

In TS you’d write (pseudocode):

function pathFromGitBytes(bytes: Buffer): string | undefined;