https://bugs.webkit.org/show_bug.cgi?id=67628
Git patches are encoded using two mechanisms - "literal" and "delta".
See this email from the git mailing list archive for info
http://marc.info/?l=git&m=
114682417113315&w=2
When determining if a binary file patch is an image or not we should accept
both literal and delta patch encodings.
Patch by Ben Wells <benwells@chromium.org> on 2011-09-06
Reviewed by Shinichiro Hamaji.
* PrettyPatch/PrettyPatch.rb:
* PrettyPatch/PrettyPatch_test.rb:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@94554
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-06 Ben Wells <benwells@chromium.org>
+
+ PrettyPatch should handle "delta" patch mechanism in git binary patches
+ https://bugs.webkit.org/show_bug.cgi?id=67628
+
+ Git patches are encoded using two mechanisms - "literal" and "delta".
+ See this email from the git mailing list archive for info
+ http://marc.info/?l=git&m=114682417113315&w=2
+
+ When determining if a binary file patch is an image or not we should accept
+ both literal and delta patch encodings.
+
+ Reviewed by Shinichiro Hamaji.
+
+ * PrettyPatch/PrettyPatch.rb:
+ * PrettyPatch/PrettyPatch_test.rb:
+
2011-06-30 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
def self.prettify(string)
$last_prettify_file_count = -1
- $last_prettify_part_count = { "remove" => 0, "add" => 0, "shared" => 0 }
+ $last_prettify_part_count = { "remove" => 0, "add" => 0, "shared" => 0, "binary" => 0 }
string = normalize_line_ending(string)
fileDiffs = FileDiff.parse(string)
GIT_BINARY_FILE_MARKER_FORMAT = /^GIT binary patch$/
- GIT_LITERAL_FORMAT = /^literal \d+$/
+ GIT_BINARY_PATCH_FORMAT = /^(literal|delta) \d+$/
START_OF_BINARY_DATA_FORMAT = /^[0-9a-zA-Z\+\/=]{20,}/ # Assume 20 chars without a space is base64 binary data.
@git_indexes = [$1, $2]
when GIT_BINARY_FILE_MARKER_FORMAT
@binary = true
- if (GIT_LITERAL_FORMAT.match(lines[i + 1]) and PrettyPatch.has_image_suffix(@filename)) then
+ if (GIT_BINARY_PATCH_FORMAT.match(lines[i + 1]) and PrettyPatch.has_image_suffix(@filename)) then
@git_image = true
startOfSections = i + 1
end
end
end
elsif @binary then
+ $last_prettify_part_count["binary"] += 1
str += "<span class='text'>Binary file, nothing to see here</span>"
else
str += @sections.collect{ |section| section.to_html }.join("<br>\n") unless @sections.nil?
80852 => ["Changes one line plus ChangeLog", 2, 2, 1, 4],
83127 => ["Only add stuff", 2, 2, 0, 3],
85071 => ["Adds and removes from a file plus git signature", 2, 5, 3, 9],
+ 104633 => ["Delta mechanism for binary patch in git diff", 12, 3, 5, 3],
}
def get_patch_uri(id)
assert_equal(info[Info::ADD], $last_prettify_part_count["add"], "Wrong number of 'add' parts in " + description)
assert_equal(info[Info::REMOVE], $last_prettify_part_count["remove"], "Wrong number of 'remove' parts in " + description)
assert_equal(info[Info::SHARED], $last_prettify_part_count["shared"], "Wrong number of 'shared' parts in " + description)
+ assert_equal(0, $last_prettify_part_count["binary"], "Wrong number of 'binary' parts in " + description)
end
def test_patches