summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-10-26 21:39:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-10-26 21:49:31 (GMT)
commit72fac66bca302dbecbe42dfa0ddc7e42db2fe567 (patch)
tree97e26848665103abaa696be186d549e747e7a8ea /merge-recursive.c
parentf78d1fe208d3db36afecbd8b8a84d6c35391bd0b (diff)
downloadgit-72fac66bca302dbecbe42dfa0ddc7e42db2fe567.zip
git-72fac66bca302dbecbe42dfa0ddc7e42db2fe567.tar.gz
git-72fac66bca302dbecbe42dfa0ddc7e42db2fe567.tar.bz2
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index fdb7d0f..a1ee9b7 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1535,13 +1535,17 @@ static int read_sha1_strbuf(const unsigned char *sha1, struct strbuf *dst)
}
static int blob_unchanged(const unsigned char *o_sha,
+ unsigned o_mode,
const unsigned char *a_sha,
+ unsigned a_mode,
int renormalize, const char *path)
{
struct strbuf o = STRBUF_INIT;
struct strbuf a = STRBUF_INIT;
int ret = 0; /* assume changed for safety */
+ if (a_mode != o_mode)
+ return 0;
if (sha_eq(o_sha, a_sha))
return 1;
if (!renormalize)
@@ -1727,8 +1731,8 @@ static int process_entry(struct merge_options *o,
} else if (o_sha && (!a_sha || !b_sha)) {
/* Case A: Deleted in one */
if ((!a_sha && !b_sha) ||
- (!b_sha && blob_unchanged(o_sha, a_sha, normalize, path)) ||
- (!a_sha && blob_unchanged(o_sha, b_sha, normalize, path))) {
+ (!b_sha && blob_unchanged(o_sha, o_mode, a_sha, a_mode, normalize, path)) ||
+ (!a_sha && blob_unchanged(o_sha, o_mode, b_sha, b_mode, normalize, path))) {
/* Deleted in both or deleted in one and
* unchanged in the other */
if (a_sha)