Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx> --- builtin/apply.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/builtin/apply.c b/builtin/apply.c index 8b7a8e0..69bb94c 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -3891,7 +3891,7 @@ static int preimage_sha1_in_gitlink_patch(struct patch *p, unsigned char sha1[20 } /* Build an index that contains the just the files needed for a 3way merge */ -static void build_fake_ancestor(struct patch *list, const char *filename) +static int build_fake_ancestor(struct patch *list, const char *filename) { struct patch *patch; struct index_state result = { NULL }; @@ -3913,31 +3913,34 @@ static void build_fake_ancestor(struct patch *list, const char *filename) if (!preimage_sha1_in_gitlink_patch(patch, sha1)) ; /* ok, the textual part looks sane */ else - die("sha1 information is lacking or useless for submodule %s", - name); + return error("sha1 information is lacking or " + "useless for submodule %s", name); } else if (!get_sha1_blob(patch->old_sha1_prefix, sha1)) { ; /* ok */ } else if (!patch->lines_added && !patch->lines_deleted) { /* mode-only change: update the current */ if (get_current_sha1(patch->old_name, sha1)) - die("mode change for %s, which is not " - "in current HEAD", name); + return error("mode change for %s, which is not " + "in current HEAD", name); } else - die("sha1 information is lacking or useless " - "(%s).", name); + return error("sha1 information is lacking or useless " + "(%s).", name); ce = make_cache_entry(patch->old_mode, sha1, name, 0, 0); if (!ce) - die(_("make_cache_entry failed for path '%s'"), name); + return error(_("make_cache_entry failed for path '%s'"), + name); if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD)) - die ("Could not add %s to temporary index", name); + return error("Could not add %s to temporary index", + name); } hold_lock_file_for_update(&lock, filename, LOCK_DIE_ON_ERROR); if (write_locked_index(&result, &lock, COMMIT_LOCK)) - die ("Could not write temporary index to %s", filename); + return error("Could not write temporary index to %s", filename); discard_index(&result); + return 0; } static void stat_patch_list(struct apply_state *state, struct patch *patch) @@ -4470,8 +4473,9 @@ static int apply_patch(struct apply_state *state, return 1; } - if (state->fake_ancestor) - build_fake_ancestor(list, state->fake_ancestor); + if (state->fake_ancestor && + build_fake_ancestor(list, state->fake_ancestor)) + return -1; if (state->diffstat) stat_patch_list(state, list); -- 2.8.1.300.g5fed0c0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html