diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-05-16 15:31:18 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-07-09 14:36:26 -0700 |
commit | 15793646acba291dc2709cb82d3f72cd5be8c6c0 (patch) | |
tree | 44bf9b92569ad1bb265063d93d19be1d771b3213 /builtin/apply.c | |
parent | a3935e6791c619a9f2f472e9e553d45d88c4e263 (diff) | |
download | git-15793646acba291dc2709cb82d3f72cd5be8c6c0.tar.gz git-15793646acba291dc2709cb82d3f72cd5be8c6c0.tar.xz |
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>
Diffstat (limited to 'builtin/apply.c')
-rw-r--r-- | builtin/apply.c | 24 |
1 files changed, 15 insertions, 9 deletions
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; |