module Git::Repository::StatusOperations::Private
Private helpers local to {Git::Repository::StatusOperations}
@api private
Public Instance Methods
Source
# File lib/git/repository/status_operations.rb, line 173 def split_status_line(line) parts = line.split("\t") parts[-1] = unescape_quoted_path(parts[-1]) parts end
Split a tab-delimited status line from ‘git ls-files –stage` output
The output format is ‘<mode> <sha> <stage>t<file>`. Quoted file paths (which git uses when the path contains non-ASCII or special characters) are unescaped before being returned. `line` is assumed to be non-empty because `git ls-files –stage` never emits blank lines.
@param line [String] a single line of git ls-files output
@return [Array<String>] the tab-delimited parts with the last part
unescaped when it was git-quoted
Source
# File lib/git/repository/status_operations.rb, line 189 def unescape_quoted_path(path) if path.start_with?('"') && path.end_with?('"') Git::EscapedPath.new(path[1..-2]).unescape else path end end
Unescape a git-quoted path
Git wraps paths containing non-ASCII or special characters in double-quotes and octal-escapes each byte. This method strips the surrounding quotes and delegates unescaping to {Git::EscapedPath}.
@param path [String] the path as it appears in git output
@return [String] the unescaped path