Skip to content

Fix issue #184 (Git status crashes on empty repo) #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Preventing Git::Diff from parsing files content as diff metadata
fix #196
  • Loading branch information
robertodecurnex authored and othatbrian committed Dec 8, 2014
commit e50e96968b3468e5892d782342c6cbedc1b593a5
15 changes: 10 additions & 5 deletions lib/git/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,25 @@ def cache_stats

# break up @diff_full
def process_full_diff
defaults = {
:mode => '',
:src => '',
:dst => '',
:type => 'modified'
}
final = {}
current_file = nil
@full_diff.split("\n").each do |line|
if m = /diff --git a\/(.*?) b\/(.*?)/.match(line)
if m = /^diff --git a\/(.*?) b\/(.*?)/.match(line)
current_file = m[1]
final[current_file] = {:patch => line, :path => current_file,
:mode => '', :src => '', :dst => '', :type => 'modified'}
final[current_file] = defaults.merge({:patch => line, :path => current_file})
else
if m = /index (.......)\.\.(.......)( ......)*/.match(line)
if m = /^index (.......)\.\.(.......)( ......)*/.match(line)
final[current_file][:src] = m[1]
final[current_file][:dst] = m[2]
final[current_file][:mode] = m[3].strip if m[3]
end
if m = /(.*?) file mode (......)/.match(line)
if m = /^([[:alpha:]]*?) file mode (......)/.match(line)
final[current_file][:type] = m[1]
final[current_file][:mode] = m[2]
end
Expand Down