2

There is an xml file in my project: mainWindow.ui. It is Qt Designer file for the GUI. For every single icon and other resource, there is a line like:

<iconset resource="../build/resources.qrc">

The problem is that resources.qrc is a configured file whose location depends on the particular user's build directory (which tends to be different for everyone depending on their preferences, e.g.

<iconset resource="../../build/resources.qrc">

This leads to an enfuriating battle between developers who edit mainWindow.ui, because they change about 50 lines every time, and this means a long and tedious manual merge for this file every single time a merge request happens.

Without making mainWindow.ui a configured file as well, can I tell git not to allow changes to those lines, or can I tell Qt Designer to fix that location? How can I avoid this situation?

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
Philip G. Lee
  • 420
  • 1
  • 3
  • 8
  • 2
    .ui files must not depend on user's build directory. .qrc file should be placed in the source directory, and its path doesn't depend on build directory path. May be you are doing something wrong. – Pavel Strakhov Jun 16 '13 at 18:48
  • I agree with Riateche. *.qrc files are part of project so it should be in repository, ergo relative position of this file should be same for everyone. – Marek R Jun 16 '13 at 22:28
  • Our resource file contains a generated file, and must be configured. – Philip G. Lee Jun 17 '13 at 04:06

1 Answers1

1

You could set up a .gitattributes file that can specifify that all merge conflicts are resolved using our settings:

 mainWindow.ui merge=ours

This will stop the mainWindow.ui from being overwritten by merges. Instead of conflicting, this will silently resolve the merge by accepting the current state of the file. This can be good if the developers have their own branches with settings in. If they work directly on master it will be less good, since they will then push their own settings.

Alternatively, and probably better in your case, each developer could force git to ignore changes to mainWindow.ui:

git update-index --skip-worktree mainWindow.ui

This is quite confusing, but it makes Git disregard changes in the file when pushing but Git still tries to preserve the changes in the local file when pulling, only updating it if the remote is updated. An overview can be found here.

Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158