Custom git diff ignore some conflicts

I am running tests to migrate from cvs to git and I have a problem in all my tests.

We keep a custom copy of FreeBSD sources, so in cvs we do the following when the new version of FreeBSD is released:

  • Import new freebsd src as a vendor branch
  • Combine changes in HEAD

I tried to do the same with git and it worked, but almost all FreeBSD files have a user identifier like this:

$FreeBSD: release/7.0.0/COPYRIGHT 175036 2008-01-01 09:36:30Z imp $

These lines always change, and due to the place where they are stored in the svn repository (release / 7.0.0, 7.1.0, 7.2.0), git generates a lot of conflicts that need to be fixed manually.

I would like to know if there is a way to configure git to simply ignore the differences in these lines and use a new one without a request.

I can do this with the diff command, ignoring these lines, for example:

diff -q -I'[$]FreeBSD:.*$'

Thanks in advance.

+4
source share
1 answer

I'm not sure that you can avoid conflict during mergers due to these changes.

What you can do, however, is a little script that can list all the files that will be merged, make your diff -q -I'[$]FreeBSD:.*$' For each of them, and for those who have no differences, follow

 git checkout --theirs theFreeBSDFile 

then resuming the merger will be able to complete the conflicting merge.

" git checkout --theirs " will git checkout --theirs stage number 3 (s) for unconnected paths.

Actually, git mergetool will be perfect for the task: before merging with FreeBSD files, set the mergetool utility to this script as described in the question Is it possible for git -merge to ignore the difference in line ends? . If you configure the mergetool configuration to trust the exit code of this script, any file that does not display any differences other than the FreeBSD custom strings will be " git checkout --theirs " and, as reported, "merged", the other will not be merged the same script.
In the end, if a conflicting file is still displayed in the resume, reset your merge tool to your favorite diffftool and resolve the remaining conflicting files.

+1
source

All Articles