Skip to content

Commit 29cbae7

Browse files
hotchpotchschacon
authored andcommitted
- DiffFile#binary?
-- check binary - attr_reader from, to (I refer to commit sha1.) Signed-off-by: Scott Chacon <schacon@gmail.com>
1 parent ba8a413 commit 29cbae7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/git/diff.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def initialize(base, from = nil, to = nil)
1818
@from = from.to_s
1919
@to = to.to_s
2020
end
21+
attr_reader :from, :to
2122

2223
def path(path)
2324
@path = path
@@ -80,6 +81,11 @@ def initialize(base, hash)
8081
@src = hash[:src]
8182
@dst = hash[:dst]
8283
@type = hash[:type]
84+
@binary = hash[:binary]
85+
end
86+
87+
def binary?
88+
!!@binary
8389
end
8490

8591
def blob(type = :dst)
@@ -131,11 +137,14 @@ def process_full_diff
131137
final[current_file][:type] = m[1]
132138
final[current_file][:mode] = m[2]
133139
end
140+
if m = /^Binary files /.match(line)
141+
final[current_file][:binary] = true
142+
end
134143
final[current_file][:patch] << "\n" + line
135144
end
136145
end
137146
final.map { |e| [e[0], DiffFile.new(@base, e[1])] }
138147
end
139148

140149
end
141-
end
150+
end

0 commit comments

Comments
 (0)