All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Buchacher <drizzd@aon.at>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH] merge-recursive: cause a conflict if file mode does not match
Date: Thu, 13 Mar 2008 20:22:46 +0100	[thread overview]
Message-ID: <20080313192246.GA30361@localhost> (raw)
In-Reply-To: <alpine.LSU.1.00.0803131607030.1656@racer.site>

Previously, mismatching file modes would be auto-merged by picking the
mode in the remote tree.

This also fixes a bug which caused merge-recursive to fail if the merged
files were empty.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---

Hi Dscho,

Your patch certainly fixes a bug in git-merge-file. It does not fix the bug in
git-merge-recursive, however. The test script also fails with your patch.

On Thu, Mar 13, 2008 at 04:19:35PM +0100, Johannes Schindelin wrote:
> On Sat, Mar 08, 2008 at 06:17:26PM +0100, Clemens Buchacher wrote:
> > One could argue that it would be better to mark the mismatching 
> > permissions as a conflict.
> 
> Right you are.  Your whole "it still is xdl_merge()s fault" point was just 
> contradicted by your own analysis.  Calling xdl_merge() when the sha1 does 
> _not_ differ is _a mistake_.  _That_ is the bug.

Alright, fixed in the appended patch.

Regards,
Clemens

 merge-recursive.c          |    9 +++++++--
 t/t6031-merge-recursive.sh |   23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)
 create mode 100755 t/t6031-merge-recursive.sh

diff --git a/merge-recursive.c b/merge-recursive.c
index 34e3167..01918a7 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1028,9 +1028,14 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
 		if (!sha_eq(a->sha1, o->sha1) && !sha_eq(b->sha1, o->sha1))
 			result.merge = 1;
 
-		result.mode = a->mode == o->mode ? b->mode: a->mode;
+		if (!o->mode) {
+			if (a->mode != b->mode)
+				result.clean = 0;
+			result.mode = b->mode;
+		} else
+			result.mode = a->mode == o->mode ? b->mode: a->mode;
 
-		if (sha_eq(a->sha1, o->sha1))
+		if (sha_eq(a->sha1, b->sha1) || sha_eq(a->sha1, o->sha1))
 			hashcpy(result.sha, b->sha1);
 		else if (sha_eq(b->sha1, o->sha1))
 			hashcpy(result.sha, a->sha1);
diff --git a/t/t6031-merge-recursive.sh b/t/t6031-merge-recursive.sh
new file mode 100755
index 0000000..7ea371e
--- /dev/null
+++ b/t/t6031-merge-recursive.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+test_description='merge-recursive corner cases'
+. ./test-lib.sh
+
+test_expect_success 'merge empty files with different permission flags' '
+	: >dummy &&
+	git add dummy &&
+	git commit -m "initial commit" &&
+	git checkout -b a master &&
+	: >a &&
+	git add a &&
+	git commit -m "branch a" &&
+	git checkout -b b master &&
+	: >a &&
+	chmod +x a &&
+	git add a &&
+	git commit -m "branch b" &&
+	git checkout master &&
+	! (git merge-recursive master -- a b || test $? -ne 1)
+'
+
+test_done
-- 
1.5.4.4.2.gd2fe

  parent reply	other threads:[~2008-03-13 19:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-08 17:17 [PATCH] fix recursive-merge of empty files with different permissions Clemens Buchacher
2008-03-08 17:51 ` Johannes Schindelin
2008-03-13 12:52   ` Clemens Buchacher
2008-03-13 15:19     ` Johannes Schindelin
2008-03-13 18:50       ` Junio C Hamano
2008-03-13 21:28         ` Johannes Schindelin
2008-03-13 19:22       ` Clemens Buchacher [this message]
2008-03-13 21:17         ` [PATCH] merge-recursive: cause a conflict if file mode does not match Johannes Schindelin
2008-03-13 22:47           ` [PATCH] merge-recursive: handle file mode changes Clemens Buchacher
2008-03-13 23:40             ` Johannes Schindelin
2008-03-14  9:21               ` [PATCH] merge-recursive: handle file mode and links similarly to file content Clemens Buchacher
2008-03-14 10:13                 ` Clemens Buchacher
2008-03-14  0:08             ` [PATCH] merge-recursive: handle file mode changes Junio C Hamano
2008-03-14  0:12             ` Junio C Hamano
2008-03-14 13:02               ` Clemens Buchacher
2008-03-14  0:17             ` Jakub Narebski
2008-03-14 12:56               ` Clemens Buchacher
2008-03-14 10:15             ` Junio C Hamano
2008-03-14 12:17               ` Clemens Buchacher
2008-03-14 16:01                 ` Junio C Hamano
2008-03-14 17:28                   ` Clemens Buchacher
2008-03-14 17:49                     ` Junio C Hamano
2008-03-14 10:07           ` [PATCH] merge-recursive: cause a conflict if file mode does not match Clemens Buchacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080313192246.GA30361@localhost \
    --to=drizzd@aon.at \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.