mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
Skip next NUL separated git status field for renames
In the `-z` git status format, a NUL follows each file name. When files are renamed, the status field is followed by a space, the "to" path, a NUL character, the "from" path and a terminating NUL. This fixes #185.
This commit is contained in:
parent
51fe55cc8f
commit
8b0ea26c01
1 changed files with 6 additions and 1 deletions
|
@ -4,8 +4,13 @@ module ColorLS
|
|||
@git_status = {}
|
||||
|
||||
IO.popen(['git', '-C', repo_path, 'status', '--porcelain', '-z', '-unormal', '--ignored']) do |output|
|
||||
output.read.split("\x0").map { |x| x.split(' ', 2) }.each do |mode, file|
|
||||
while (status_line = output.gets "\x0")
|
||||
mode, file = status_line.chomp("\x0").split(' ', 2)
|
||||
|
||||
@git_status[file] = mode
|
||||
|
||||
# skip the next \x0 separated original path for renames, issue #185
|
||||
output.gets("\x0") if mode.start_with? 'R'
|
||||
end
|
||||
end
|
||||
warn "git status failed in #{repo_path}" unless $CHILD_STATUS.success?
|
||||
|
|
Loading…
Reference in a new issue