9

I would like to set up a Git repository with a custom merge driver, and then disable rename detection when merging.

The problem is that, if I use the default recursive strategy, I cannot disable rename detection, and if I use the resolve strategy (not ideal, but good enough), the merge driver is ignored.

Note that I would like to avoid rename detection even when the file contents perfectly match.

.git/config:

[merge "my"]
    name = my merge
    driver = my_merge_driver %A %O %B
[merge]
    default = my

Attempts:

$ git merge -X rename-threshold=200%  # Equivalent to 100%
$ git merge -s resolve                # Custom driver ignored
$ git --version                       # git version 2.2.0-rc0
filipos
  • 645
  • 6
  • 12
  • Is it still ignore with git 2.7.0? – VonC Feb 04 '16 at 05:53
  • 1
    I guess it is still ignored, reading my old answer http://stackoverflow.com/a/22579625/6309 – VonC Feb 04 '16 at 07:13
  • Indeed, @VonC, I can confirm the exact same behaviour with git version 2.7.0. – filipos Feb 04 '16 at 11:42
  • Can you provide any details of what your custom merge driver `my_merge_driver` does, or what problems it solves? – javabrett Feb 10 '16 at 00:37
  • @javabrett The file contents represent version numbers. The driver basically favours latest versions. The repository represents de facto histories in a system where files (or any logical units) are independently versioned. – filipos Feb 10 '16 at 06:24
  • Have you looked into pulling your merge-driver logic up into a custom merge-strategy instead? You could possibly chain this strategy to call the existing resolve strategy script after your version-number logic has done what it needs to do. – javabrett Feb 11 '16 at 00:09
  • @javabrett That is certainly an option, but, if possible, I would prefer to reuse the logic in the recursive strategy (except for rename detection, of course). – filipos Feb 11 '16 at 00:37

2 Answers2

2

As of Git 2.8.0.rc0, the merge-recursive algorithm now accepts an option "no-renames" (commit 4ce064d), so my problem is now solved by

$ git merge -X no-renames
filipos
  • 645
  • 6
  • 12
1

Taking into account the use case you're planning for this, A good workaround would be to write the filename, along with the version number, in each file.

thePiGrepper
  • 183
  • 7
  • I find it a bit ugly, and it will require some (simple) changes on code handling the repository, but, well, it works. Expiring bounty granted. I will wait some more time to see if other answers appear before accepting one. – filipos Feb 11 '16 at 00:45