@matheusbsbs / matheus-bagliano / commits / 03eb8f8aeb
Fork 0

builtin-apply --reverse: two bugfixes.

Parsing of a binary hunk did not consume the terminating blank line. When applying in reverse, it did not use the second, reverse binary hunk. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Aug 16, 2006 at 16:07 UTC 03eb8f8aeb8a483b11b797cca012fdded818a5c1
1 file changed +7 -3
builtin-apply.c
+7 -3
@@ -1063,8 +1063,12 @@ static struct fragment *parse_binary_hunk(char **buf_p,
1063 llen = linelen(buffer, size);
1064 used += llen;
1065 linenr++;
1066 - if (llen == 1)
1066 + if (llen == 1) {
1067 + /* consume the blank line */
1068 + buffer++;
1069 + size--;
1070 break;
1071 + }
1072 /* Minimum line is "A00000\n" which is 7-byte long,
1073 * and the line length must be multiple of 5 plus 2.
1074 */
@@ -1618,7 +1622,7 @@ static int apply_binary_fragment(struct buffer_desc *desc, struct patch *patch)
1622 "without the reverse hunk to '%s'",
1623 patch->new_name
1624 ? patch->new_name : patch->old_name);
1621 - fragment = fragment;
1625 + fragment = fragment->next;
1626 }
1627 data = (void*) fragment->patch;
1628 switch (fragment->binary_patch_method) {
@@ -1717,7 +1721,7 @@ static int apply_binary(struct buffer_desc *desc, struct patch *patch)
1721 write_sha1_file_prepare(desc->buffer, desc->size, blob_type,
1722 sha1, hdr, &hdrlen);
1723 if (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))
1720 - return error("binary patch to '%s' creates incorrect result", name);
1724 + return error("binary patch to '%s' creates incorrect result (expecting %s, got %s)", name, patch->new_sha1_prefix, sha1_to_hex(sha1));
1725 }
1726
1727 return 0;