0

I am working on a quite big project versioned on a Git repositories that have several file of different types versioned. Among those, we use the QM Modelling tool that uses .qm files, which are actually xml files with a certain structure.

The structure of the .qm and the meaning of its content makes it unadvisable to use a merging tool to merge any change.

What I would like to do is have git issue a conflict in case it finds changes to any qm file even if it could merge those changes ( even if it could, the result is not guaranteed to be meaningful ), so that I can manually merge them using the tool.

Pros if the same is true if I perform a rebase instead of a merge.

bracco23
  • 2,044
  • 8
  • 25

1 Answers1

0

Ok, answering myself as I found a solution.

I found this answer and modified it a little bit. I added a new merge strategy that basically takes the file as it is in the incoming branch and uses it untouched, then marks the file as with conflict.

So i created this script:

#!/bin/bash
# ${1} is the base common file
# ${2} is the file as modified by the base branch, and where the results must be
# ${3} is the file as modified by the incoming branch
# ${4} is the path of the file being merged

# ${4%.qm*} is the path without extension
# ${4##*.} is the extension of the path
# makes a backup of the original file to ease edits comparison
cat "${2}" > "${4%.qm*}.bk.${4##*.}"

cat "${3}" > "${2}"
exit 1

which uses the incoming file as a result as it is, and returns 1 to mark it as conflict.

Then I added in the .gitattributes the option to use this strategy for my .qm file, so that when I merge two branches, I take the incoming version as it is and use the graphical tool to modify and integrate my changes.

I'm going to leave this question as unresolved to see if anybody got another solution that would enable me to use both rebase and merge.

EDIT: I updated the script, I added a few lines to take the version of the local branch and make a backup of it, so that it is available to use in a comparison tool to identify my changes more easily.

bracco23
  • 2,044
  • 8
  • 25