2

I'm looking for a possible way of getting around some merge conflicts when working through different branches.

It's not unlikely that some information in some files (especially version numbers) are NOT to be spread around different branches, so I'm looking for some way to output a diff ignoring text between well defined sentinel lines, and I'd like to know if there's anything around without coding my own solution.

That what I'd like: suppose two source files that look like

some text
DIFF_IGNORE_START
foo bar
DIFF_IGNORE_END
some other text
one

and

some text
DIFF_IGNORE_START
different text
DIFF_IGNORE_END
some other text
two

I want the diff to be

--- original    2011-04-04 15:34:06.000000000 +0200
+++ modified    2011-04-04 15:35:13.000000000 +0200
@@ -3,4 +3,4 @@
 foo bar
 DIFF_IGNORE_END
 some other text
-one
+two

I'd need a solution that allows the ignored blocks to be of a different size as well.

Alan Franzoni
  • 3,041
  • 1
  • 23
  • 35

1 Answers1

0

One way to implement this would be through a custom diff driver, declaring a special diff script in a .gitattributes file, which would:

  • remove every DIFF_IGNORE_xxx sections on root, source and destination versions, replacing them with dummy content (always identical between the three version)
  • perform the diff with the modified versions
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hooking with git would be the easy part, but the custom diff driver is not as easy as you think - You can't substitute the content between the two tags with dummy content, because that will usually appear in the diff as diff context. – Alan Franzoni Apr 05 '11 at 13:38