Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent systematic conflicts when merging Visual C++ 2012 project filters?
    primarykey
    data
    text
    <p>When new files are added to a Visual C++ project, the IDE adds them in two locations:</p> <ul> <li>The main project file (e.g. myproject.vcxproj)</li> <li>The project "filters", a repository of the virtual paths of the solution explorer (e.g. myproject.vcxproj.filters)</li> </ul> <p>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 <strong>very end</strong> of the filter list.</p> <p>To illustrate the problem, let's say the filters initially look like this:</p> <pre class="lang-xml prettyprint-override"><code>1 &lt;ClInclude Include="fs\path\oldFile1.h"&gt; 2 &lt;Filter&gt;virtual\path&lt;/Filter&gt; 3 &lt;/ClInclude&gt; 4 &lt;ClInclude Include="fs\path\oldFile2.h"&gt; 5 &lt;Filter&gt;virtual\path&lt;/Filter&gt; 6 &lt;/ClInclude&gt; </code></pre> <p>Then programmer A add <code>newFileA.h</code> and commits, the filters are updated as follows:</p> <pre class="lang-xml prettyprint-override"><code>1 &lt;ClInclude Include="fs\path\oldFile1.h"&gt; 2 &lt;Filter&gt;virtual\path&lt;/Filter&gt; 3 &lt;/ClInclude&gt; 4 &lt;ClInclude Include="fs\path\oldFile2.h"&gt; 5 &lt;Filter&gt;virtual\path&lt;/Filter&gt; 6 &lt;/ClInclude&gt; 7 &lt;ClInclude Include="fs\path\newFileA.h"&gt; 8 &lt;Filter&gt;virtual\path&lt;/Filter&gt; 9 &lt;/ClInclude&gt; </code></pre> <p>If programmer B also adds a <code>newFileB.h</code> and is note synced on the head revision, his local copy of the filters will look like this:</p> <pre class="lang-xml prettyprint-override"><code>1 &lt;ClInclude Include="fs\path\oldFile1.h"&gt; 2 &lt;Filter&gt;virtual\path&lt;/Filter&gt; 3 &lt;/ClInclude&gt; 4 &lt;ClInclude Include="fs\path\oldFile2.h"&gt; 5 &lt;Filter&gt;virtual\path&lt;/Filter&gt; 6 &lt;/ClInclude&gt; 7 &lt;ClInclude Include="fs\path\newFileB.h"&gt; 8 &lt;Filter&gt;virtual\path&lt;/Filter&gt; 9 &lt;/ClInclude&gt; </code></pre> <p>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.</p> <p>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 (<em>preferably</em> Araxis Merge or Beyond Compare), or anything else?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COWhat is ultimately trying to do the merge? If it is something like git then you can apply a merge strategy to handle this case. In short, it really depends on the tool that is doing the merge and how it applies them. Also, as MJD said, if this is for version control you can opt to simply not commit filters and let each user have their own.
      singulars
    2. CO@micah-caldwell We're using Perforce for version control but we don't necessarily stick to P4Merge for merging. We use mostly Araxis Merge and Beyond Compare for that job. And for *not* commiting the filters, it might be a good idea, see my comment [below MJD's answer](http://stackoverflow.com/a/19474105/1005455).
      singulars
    3. COYour answer will ultimately depend on the tool that does the merge. In the case of git, there is a merge strategy that can be useful in situations like this where it will add both when two additions occur in the same place. It is possible that P4Merge, Beyond Compare and/or Araxis Merge have a similar option. I recommend re-asking your question specifically for one tool (or multiple questions, one for each tool) as the answer will be tool specific.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload