1

I have two conflicting files.

Here is the first file (a.xml):

<doc>
  <ignore name="ignore1" />
  <ignore name="ignore2" />
  <interesting name="foo.a" />
  <ignore name="ignoreN" />
  <interesting name="bar.a" />
</doc>

And here is the second one (b.xml):

<doc>
  <ignore name="ignore1" />
  <ignore name="ignore2" />
  <interesting name="foo.b" />
  <ignore name="ignoreN" />
  <interesting name="bar.b" />
</doc>

So basically it conflicts only on the interesting parts.

And I want to get this result:

<doc>
  <ignore name="ignore1" />
  <ignore name="ignore2" />
  <interesting name="foo.a" />
  <interesting name="foo.b" />
  <ignore name="ignoreN" />
  <interesting name="bar.a" />
  <interesting name="bar.b" />
</doc>

Is that possible with KDiff3 or any other merge tool ?

With KDiff3, I can do that manually but I'm looking for an automatic solution.

mikedu95
  • 1,725
  • 2
  • 12
  • 24
  • https://stackoverflow.com/a/13264117/2303202 – max630 Jan 07 '16 at 08:55
  • @max630 As noticed by Ilia G in a comment to the Dwight Holman's answer, it fails when working with XML. I'm working with XML files and want to select both lines. I've updated my question to add this precision. – mikedu95 Jan 27 '16 at 17:11
  • I tried and it seems to work at least in this simple case: http://pastebin.com/LrnAEMLs – max630 Jan 27 '16 at 20:07
  • @max630 Not tried yet but I've update my question again, and your proposition is a bit a pain to deal with to get just files merged. However, it led me to the discovering of the `git merge-file` command which is nice because it can work *without* a repo and it provides an `--union` strategy, which may be the solution I'm looking for. Time to try. – mikedu95 Jan 28 '16 at 17:19
  • you can set it up gitattributes, like described in link – max630 Jan 28 '16 at 20:24
  • Yes, maybe. Maybe because I have not tested yet because I haven't git on my current machine. But as I've noticed in my previous comment, I find it too painful to have to modify a config file just to get two files merged, then restore the config file after the merge. I'd prefer a one-shot command if possible. Hoping that `git merge-file` will do it. – mikedu95 Jan 29 '16 at 09:14

0 Answers0