X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=apply.c;h=43a0aebf4eec85fa6b0a69f655c0224aa14f29e5;hb=ed8d1d42d0ffc221340557614aa33bf8d3aba65f;hp=44bc31d6eb5b42d4077eff458246cde376cb6785;hpb=25ed97c61bbc64cfe80e35a457f3e4f447a84e11;p=thirdparty%2Fgit.git diff --git a/apply.c b/apply.c index 44bc31d6eb..43a0aebf4e 100644 --- a/apply.c +++ b/apply.c @@ -1917,6 +1917,7 @@ static struct fragment *parse_binary_hunk(struct apply_state *state, state->linenr++; buffer += llen; + size -= llen; while (1) { int byte_length, max_byte_length, newsize; llen = linelen(buffer, size); @@ -3467,6 +3468,21 @@ static int load_preimage(struct apply_state *state, return 0; } +static int resolve_to(struct image *image, const struct object_id *result_id) +{ + unsigned long size; + enum object_type type; + + clear_image(image); + + image->buf = read_object_file(result_id, &type, &size); + if (!image->buf || type != OBJ_BLOB) + die("unable to read blob object %s", oid_to_hex(result_id)); + image->len = size; + + return 0; +} + static int three_way_merge(struct apply_state *state, struct image *image, char *path, @@ -3478,6 +3494,12 @@ static int three_way_merge(struct apply_state *state, mmbuffer_t result = { NULL }; int status; + /* resolve trivial cases first */ + if (oideq(base, ours)) + return resolve_to(image, theirs); + else if (oideq(base, theirs) || oideq(ours, theirs)) + return resolve_to(image, ours); + read_mmblob(&base_file, base); read_mmblob(&our_file, ours); read_mmblob(&their_file, theirs);