git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Buchacher <drizzd@aon.at>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] fix recursive-merge of empty files with different permissions
Date: Thu, 13 Mar 2008 13:52:29 +0100	[thread overview]
Message-ID: <20080313125229.GA24758@localhost> (raw)
In-Reply-To: <alpine.LSU.1.00.0803081850470.3975@racer.site>

Hi,

On Sat, Mar 08, 2008 at 06:17:26PM +0100, Clemens Buchacher wrote:
> If git-merge-recursive attempts to merge two empty new files with
> different executable flags, eventually xdl_merge() is called and produces
> empty diffs for both files and therefore does not choose either file as
> successor. Make xdl_merge() choose one of the files instead.

On Sat, Mar 08, 2008 at 06:51:48PM +0100, Johannes Schindelin wrote:
> On Sat, 8 Mar 2008, Clemens Buchacher wrote:
> > I do not understand why, but this does not happen if the file 
> > permissions are the same.
> 
> I think this is the biggest problem.
> 
> >  t/t6031-merge-recursive.sh |   23 +++++++++++++++++++++++
> >  xdiff/xmerge.c             |   30 ++++++++++++++----------------
> 
> ... because xdiff/xmerge.c is definitely the wrong place to "fix" this 
> issue.  xdl_merge() does not even _know_ about permissions.

After analyzing the problem in greater detail, I have to disagree. It is true,
of course, that xdl_merge() does not and should not know about permissions at
all. However, the bug is still in xdl_merge(). Different permissions are only
the trigger of the problem, because only then will xdl_merge() be called at
all.

What happens is this. Before looking at the file contents directly
merge_trees() attempts to resolve the merge trivially. If both sha1 and mode of
the head and remote entries match, the merge will be resolved as per case #5ALT
(see Documentation/trivial-merge.txt), i.e. head is chosen as the merge result.

If either sha1 _or_ mode differ between the head and remote entries, however,
merge_trees() will use xdl_merge() to merge the file content and the remote
entry's mode will be chosen as result mode.

One could argue that it would be better to mark the mismatching permissions as
a conflict. However, this is how the merge currently silently succeeds _unless_
both files are empty. If they are, xdl_merge() will effectively exit with an
error status and git-merge-recursive will fail with an internal error (as shown
in the testcase).

In any case, I think it is reasonable to expect xdl_merge() to work with empty
files. Whether or not the current "mode merging" behavior is desired is a
different matter.

Regards,
Clemens

  reply	other threads:[~2008-03-13 12:53 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 [this message]
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       ` [PATCH] merge-recursive: cause a conflict if file mode does not match Clemens Buchacher
2008-03-13 21:17         ` 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=20080313125229.GA24758@localhost \
    --to=drizzd@aon.at \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).