When new files are added to a Visual C++ project, the IDE adds them in two locations:
- The main project file (e.g. myproject.vcxproj)
- The project "filters", a repository of the virtual paths of the solution explorer (e.g. myproject.vcxproj.filters)
Merging file additions is not a problem for the main project file, but it's very often a source of conflicts for the filters. The problem comes from the fact that the IDE always adds new elements at the very end of the filter list.
To illustrate the problem, let's say the filters initially look like this:
1 <ClInclude Include="fs\path\oldFile1.h">
2 <Filter>virtual\path</Filter>
3 </ClInclude>
4 <ClInclude Include="fs\path\oldFile2.h">
5 <Filter>virtual\path</Filter>
6 </ClInclude>
Then programmer A add newFileA.h
and commits, the filters are updated as follows:
1 <ClInclude Include="fs\path\oldFile1.h">
2 <Filter>virtual\path</Filter>
3 </ClInclude>
4 <ClInclude Include="fs\path\oldFile2.h">
5 <Filter>virtual\path</Filter>
6 </ClInclude>
7 <ClInclude Include="fs\path\newFileA.h">
8 <Filter>virtual\path</Filter>
9 </ClInclude>
If programmer B also adds a newFileB.h
and is note synced on the head revision, his local copy of the filters will look like this:
1 <ClInclude Include="fs\path\oldFile1.h">
2 <Filter>virtual\path</Filter>
3 </ClInclude>
4 <ClInclude Include="fs\path\oldFile2.h">
5 <Filter>virtual\path</Filter>
6 </ClInclude>
7 <ClInclude Include="fs\path\newFileB.h">
8 <Filter>virtual\path</Filter>
9 </ClInclude>
Trying to sync with the changes of programmer A will systematically provoke a merging conflict on lines 7-8-9 for programmer B. That's because the changes happen to occur at the exact same spot.
Is there a way to prevent this issue from happening, be it through a config change in Visual Studio, a special option of some merging tool (preferably Araxis Merge or Beyond Compare), or anything else?