I’m starting tests to move from cvs to git, and I have a problem on all my tests.
We maintain a custom copy of FreeBSD sources, so in cvs we do the following when a new FreeBSD version is released:
- Import new freebsd src as a vendor branch
- Merge changes on HEAD
I tried to do the same with git, and it worked, but almost all FreeBSD files have a custom Id like this:
$FreeBSD: release/7.0.0/COPYRIGHT 175036 2008-01-01 09:36:30Z imp $
These lines always change, and because of the place they are stored in the svn repository (release/7.0.0, 7.1.0, 7.2.0), git generates a lot of conflicts that needed to be fixed manually.
I would like to know if there is a way to configure git to just ignore diffs on these lines and use the new one without asking.
I can do it with diff command ignoring those lines, like this:
diff -q -I'[$]FreeBSD:.*$'
Thank you in advance.
I am not sure you can avoid conflict during merges because of those changes.
What you can do, though, is a little script able to list all files to be merges, do your
diff -q -I'[$]FreeBSD:.*$'on each of them, and for those with no differences, do athen a resume of the merge will be able to comple the conflicting merge.
The ‘
git checkout --theirs‘ check out stage #3 (theirs) for unmerged paths.Actually, a
git mergetoolwould be perfect for the job: just before a merge involving FreeBSD files, set your mergetool utility to that script, as described in the question Is it possible for git-merge to ignore line-ending differences?.If you setup the mergetool config to trust the exit code of that script, any file which does not display any differences except FreeBSD custom lines would be ‘
git checkout --theirs‘ and reportedly “merged”, the other would not be merged by the same script.At the end, if a resume still show conflicting file, reset your merge tool to your favorite difftool, and resolve the remaining conflicting files.