Skip to main content

path_label

Function path_label 

Source
pub fn path_label(path: &str) -> Cow<'_, str>
Expand description

A file name as a text report prints it.

The name is the repository’s text, and git and the filesystem allow every byte but / and NUL in one, so a branch under review can name a file with an escape sequence or a newline in it. The diff decodes git’s own quoting back to those bytes, and printed raw they reach the terminal reading the report, where a newline forges a report line of its own.

Not excerpt: a name is printed whole, because a shortened or altered one names a different file. A name holding a control character is printed as a quoted Rust string literal instead, which escapes every control character and keeps every other one. Every other name, café.rs included, is printed as it stands.