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>
Junio C Hamano committed
May 16, 2012 at 15:31 UTC
15793646acba291dc2709cb82d3f72cd5be8c6c0
1 file changed
+15
-9
builtin/apply.c
+15
-9
@@ -3218,16 +3218,22 @@ static int check_patch(struct patch *patch)
3218
return status;
3219
old_name = patch->old_name;
3220
3221
+ /*
3222
+ * A type-change diff is always split into a patch to delete
3223
+ * old, immediately followed by a patch to create new (see
3224
+ * diff.c::run_diff()); in such a case it is Ok that the entry
3225
+ * to be deleted by the previous patch is still in the working
3226
+ * tree and in the index.
3227
+ *
3228
+ * A patch to swap-rename between A and B would first rename A
3229
+ * to B and then rename B to A. While applying the first one,
3230
+ * the presense of B should not stop A from getting renamed to
3231
+ * B; ask to_be_deleted() about the later rename. Removal of
3232
+ * B and rename from A to B is handled the same way by asking
3233
+ * was_deleted().
3234
+ */
3235
if ((tpatch = in_fn_table(new_name)) &&
3222
- (was_deleted(tpatch) || to_be_deleted(tpatch)))
3223
- /*
3224
- * A type-change diff is always split into a patch to
3225
- * delete old, immediately followed by a patch to
3226
- * create new (see diff.c::run_diff()); in such a case
3227
- * it is Ok that the entry to be deleted by the
3228
- * previous patch is still in the working tree and in
3229
- * the index.
3230
- */
3236
+ (was_deleted(tpatch) || to_be_deleted(tpatch)))
3237
ok_if_exists = 1;
3238
else
3239
ok_if_exists = 0;