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 <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2012-05-16 15:31:18 -07:00
Родитель a3935e6791
Коммит 15793646ac
1 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -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;