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 --- git-merge-one-file.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'git-merge-one-file.sh') diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index 07dfeb8df4..cdc02af517 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -38,6 +38,14 @@ case "${1:-.}${2:-.}${3:-.}" in # Deleted in both or deleted in one and unchanged in the other # "$1.." | "$1.$1" | "$1$1.") + if { test -z "$6" && test "$5" != "$7"; } || + { test -z "$7" && test "$5" != "$6"; } + then + echo "ERROR: File $4 deleted on one branch but had its" >&2 + echo "ERROR: permissions changed on the other." >&2 + exit 1 + fi + if test -n "$2" then echo "Removing $4" -- cgit v1.3-6-g1900