From 72fac66bca302dbecbe42dfa0ddc7e42db2fe567 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 26 Oct 2015 17:39:39 -0400 Subject: merge: detect delete/modechange conflict If one side deletes a file and the other changes its content, we notice and report a conflict. However, if instead of changing the content, we change only the mode, the merge does not notice (and the mode change is silently dropped). The trivial index merge notices the problem and correctly leaves the conflict in the index, but both merge-recursive and merge-one-file will silently resolve this in favor of the deletion. In many cases that is a sane resolution, but we should be punting to the user whenever there is any question. So let's detect and treat this as a conflict (in both strategies). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t6031-merge-filemode.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 't') diff --git a/t/t6031-merge-filemode.sh b/t/t6031-merge-filemode.sh index c6896e674c..7d06461f13 100755 --- a/t/t6031-merge-filemode.sh +++ b/t/t6031-merge-filemode.sh @@ -74,4 +74,27 @@ do_both_modes () { do_both_modes recursive do_both_modes resolve +test_expect_success 'set up delete/modechange scenario' ' + git reset --hard && + git checkout -b deletion master && + git rm file1 && + git commit -m deletion +' + +do_delete_modechange () { + strategy=$1 + us=$2 + them=$3 + test_expect_success "detect delete/modechange conflict ($strategy, $us)" ' + git reset --hard && + git checkout $us && + test_must_fail git merge -s $strategy $them + ' +} + +do_delete_modechange recursive b1 deletion +do_delete_modechange recursive deletion b1 +do_delete_modechange resolve b1 deletion +do_delete_modechange resolve deletion b1 + test_done -- cgit v1.2.3