git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [sort-of-BUG] merge-resolve cannot resolve "content/mode" conflict
Date: Sun, 3 Apr 2016 01:26:28 -0400	[thread overview]
Message-ID: <20160403052627.GA10487@sigill.intra.peff.net> (raw)

Imagine a merge where one side changes the content of a path and the
other changes the mode. Here's a minimal reproduction:

  git init repo && cd repo &&

  echo base >file &&
  git add file &&
  git commit -m base &&

  echo changed >file &&
  git commit -am content &&

  git checkout -b side HEAD^
  chmod +x file &&
  git commit -am mode

If I merge that with merge-recursive, I get what you'd expect: mode
10755, and content "changed".

However, with merge-resolve, I get a conflict:

  $ git merge -s resolve master
  Trying really trivial in-index merge...
  error: Merge requires file-level merging
  Nope.
  Trying simple merge.
  Simple merge failed, trying Automatic merge.
  Auto-merging file
  ERROR: permissions conflict: 100644->100755,100644 in file
  fatal: merge program failed
  Automatic merge failed; fix conflicts and then commit the result.

I think this is only a half-bug, really. It's definitely a funny
situation, and it's not unreasonable for a merge driver to punt on a
funny situation rather than resolving it. But I would say:

  - it would probably be a nice improvement to resolve this as
    merge-recursive does

  - the "ERROR" message is silly and misleading; the permissions resolve
    just fine, it is only that the combination with the content-level
    change confuses the script (but the output does not mention that).

This is a leftover from my experiments with merge-resolve versus
merge-recursive last fall, which resulted in a few actual bug-fixes. I
looked into fixing this case, too, at that time. It seemed possible, but
a little more involved than you might think (because the logic is driven
by a bunch of case statements, and this adds a multiplicative layer to
the cases; we might need to resolve the permissions, and _then_ see if
the content can be resolved).

So I didn't actually come up with a patch, but I figured I'd write it up
here for posterity. And just didn't get around to it until now.

-Peff

             reply	other threads:[~2016-04-03  5:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-03  5:26 Jeff King [this message]
2016-04-04 17:34 ` [sort-of-BUG] merge-resolve cannot resolve "content/mode" conflict Junio C Hamano
2016-05-19  1:03   ` Jeff King

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=20160403052627.GA10487@sigill.intra.peff.net \
    --to=peff@peff.net \
    --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).