summaryrefslogtreecommitdiff
path: root/builtin-apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-08-16 16:07:20 -0700
committerJunio C Hamano <junkio@cox.net>2006-08-16 21:08:45 -0700
commit03eb8f8aeb8a483b11b797cca012fdded818a5c1 (patch)
tree5f9155b3b26652c310ee35023313f2d95adf0a6b /builtin-apply.c
parent409d1d2053657f73a3222651111740606122aa80 (diff)
downloadgit-03eb8f8aeb8a483b11b797cca012fdded818a5c1.tar.gz
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>
Diffstat (limited to 'builtin-apply.c')
-rw-r--r--builtin-apply.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/builtin-apply.c b/builtin-apply.c
index 4f0eef0ac3..be6e94d367 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1063,8 +1063,12 @@ static struct fragment *parse_binary_hunk(char **buf_p,
llen = linelen(buffer, size);
used += llen;
linenr++;
- if (llen == 1)
+ if (llen == 1) {
+ /* consume the blank line */
+ buffer++;
+ size--;
break;
+ }
/* Minimum line is "A00000\n" which is 7-byte long,
* and the line length must be multiple of 5 plus 2.
*/
@@ -1618,7 +1622,7 @@ static int apply_binary_fragment(struct buffer_desc *desc, struct patch *patch)
"without the reverse hunk to '%s'",
patch->new_name
? patch->new_name : patch->old_name);
- fragment = fragment;
+ fragment = fragment->next;
}
data = (void*) fragment->patch;
switch (fragment->binary_patch_method) {
@@ -1717,7 +1721,7 @@ static int apply_binary(struct buffer_desc *desc, struct patch *patch)
write_sha1_file_prepare(desc->buffer, desc->size, blob_type,
sha1, hdr, &hdrlen);
if (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))
- return error("binary patch to '%s' creates incorrect result", name);
+ return error("binary patch to '%s' creates incorrect result (expecting %s, got %s)", name, patch->new_sha1_prefix, sha1_to_hex(sha1));
}
return 0;