From 18cdf802ca6e2772b5901f786f59de3843299b1c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 10 Nov 2008 15:49:03 -0800 Subject: Teach "apply --index-info" to handle rename patches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With v1.5.3.2~14 (apply --index-info: fall back to current index for mode changes, 2007-09-17), git apply learned to stop worrying about the lack of diff index line when a file already present in the current index had no content change. But it still worries too much: for rename patches, it is checking that both the old and new filename are present in the current index. This makes no sense, since a file rename generally involves creating a file there was none before. So just check the old filename. Noticed while trying to use “git rebase” with diff.renames = copies. [jn: add tests] Reported-by: David D. Kilzer Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/apply.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/apply.c b/builtin/apply.c index 12ef9ea8af..f38c1f7b88 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -2979,8 +2979,7 @@ static void build_fake_ancestor(struct patch *list, const char *filename) else if (get_sha1(patch->old_sha1_prefix, sha1)) /* git diff has no index line for mode/type changes */ if (!patch->lines_added && !patch->lines_deleted) { - if (get_current_sha1(patch->new_name, sha1) || - get_current_sha1(patch->old_name, sha1)) + if (get_current_sha1(patch->old_name, sha1)) die("mode change for %s, which is not " "in current HEAD", name); sha1_ptr = sha1; -- cgit v1.2.1