From: Junio C Hamano Date: Wed, 16 May 2012 22:31:18 +0000 (-0700) Subject: apply: fix an incomplete comment in check_patch() X-Git-Tag: v1.7.12-rc0~31^2~18 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=15793646acba291dc2709cb82d3f72cd5be8c6c0;p=git.git apply: fix an incomplete comment in check_patch() This check is not only about type-change (for which it would be sufficient to check only was_deleted()) but is also about a swap rename. Otherwise to_be_deleted() check is not justified. Signed-off-by: Junio C Hamano --- diff --git a/builtin/apply.c b/builtin/apply.c index 725712d78..44f6de903 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -3218,16 +3218,22 @@ static int check_patch(struct patch *patch) return status; old_name = patch->old_name; + /* + * A type-change diff is always split into a patch to delete + * old, immediately followed by a patch to create new (see + * diff.c::run_diff()); in such a case it is Ok that the entry + * to be deleted by the previous patch is still in the working + * tree and in the index. + * + * A patch to swap-rename between A and B would first rename A + * to B and then rename B to A. While applying the first one, + * the presense of B should not stop A from getting renamed to + * B; ask to_be_deleted() about the later rename. Removal of + * B and rename from A to B is handled the same way by asking + * was_deleted(). + */ if ((tpatch = in_fn_table(new_name)) && - (was_deleted(tpatch) || to_be_deleted(tpatch))) - /* - * A type-change diff is always split into a patch to - * delete old, immediately followed by a patch to - * create new (see diff.c::run_diff()); in such a case - * it is Ok that the entry to be deleted by the - * previous patch is still in the working tree and in - * the index. - */ + (was_deleted(tpatch) || to_be_deleted(tpatch))) ok_if_exists = 1; else ok_if_exists = 0;