{"thread":{"id":"38707","subject":"Git merge driver / attributes bug in 2.3.1?","startedAt":"2015-03-05T13:30:40Z","lastAt":"2015-03-09T09:35:15Z","messageCount":8,"participants":["Gondek, Andreas","Junio C Hamano","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"257072","messageId":"D8780C527EB1E642B3150E6D705B46D448E7E48C@DWPWHMS531.dwpbank.local","threadId":"38707","inReplyTo":null,"subject":"Git merge driver / attributes bug in 2.3.1?","fromName":"Gondek, Andreas","fromEmail":"andreas.gondek@dwpbank.de","sentAt":"2015-03-05T13:30:40Z","receivedAt":"2015-03-05T13:30:40Z","isPatch":false,"sender":{"key":"andreas.gondek@dwpbank.de","avatar":null},"body":"Hello,\n\nafter upgrading the Git installation on one of our development servers from 1.9.0-rc3 to 2.3.1 we are experiencing strange behavior of merge drivers.\n\nA merge driver registered as \"* merge=<name_of_merge_driver>\" in the .gitattributes is now executed even if there isn't any merge conflict. This only happens for files that are part of the merge.\n\nThis is reproducible in test repositories.\n\nGreetings\n\nAndreas Gondek\nApplications\n________________________________\n\nDeutsche WertpapierService Bank AG\nITTAS\nDerendorfer Allee 2\n40476 Düsseldorf\nTel.: +49 69 5099 9503\nFax: +49 69 5099 85 9503\nE-Mail: Andreas.Gondek@dwpbank.de\nhttp://www.dwpbank.de\n\nDeutsche WertpapierService Bank AG | Wildunger Straße 14 | 60487 Frankfurt am Main\nSitz der AG: Frankfurt am Main, HRB 56913 | USt.-ID: DE 813759005\nVorstand: Thomas Klanten, Dr. Christian Tonnesen\nAufsichtsrat: Wilfried Groos (Vors.) \n"},{"id":"257096","messageId":"xmqqa8zr46kv.fsf@gitster.dls.corp.google.com","threadId":"38707","inReplyTo":"D8780C527EB1E642B3150E6D705B46D448E7E48C@DWPWHMS531.dwpbank.local","subject":"Re: Git merge driver / attributes bug in 2.3.1?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-05T18:55:44Z","receivedAt":"2015-03-05T18:55:44Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Gondek, Andreas\" <Andreas.Gondek@dwpbank.de> writes:\n\n> after upgrading the Git installation on one of our development servers\n> from 1.9.0-rc3 to 2.3.1 we are experiencing strange behavior of merge\n> drivers.\n\nDo you see the same with something slightly older, like say v2.2.0?\n\nThe only change that I can think of offhand that may be related is\n6ea358f7 (ll-merge.c: refactor `read_merge_config()` to use\n`git_config_string()`, 2014-08-13) that went into v2.2.0, but I\ndon't immediately see how that would be related X-<.\n"},{"id":"257150","messageId":"54F98EBE.8080903@drmicha.warpmail.net","threadId":"38707","inReplyTo":"D8780C527EB1E642B3150E6D705B46D448E7E48C@DWPWHMS531.dwpbank.local","subject":"Re: Git merge driver / attributes bug in 2.3.1?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-06T11:25:50Z","receivedAt":"2015-03-06T11:25:50Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Gondek, Andreas venit, vidit, dixit 05.03.2015 14:30:\n> Hello,\n> \n> after upgrading the Git installation on one of our development\n> servers from 1.9.0-rc3 to 2.3.1 we are experiencing strange behavior\n> of merge drivers.\n> \n> A merge driver registered as \"* merge=<name_of_merge_driver>\" in the\n> .gitattributes is now executed even if there isn't any merge\n> conflict. This only happens for files that are part of the merge.\n> \n> This is reproducible in test repositories.\n\nCan you share a minimal test repo?\n\nI've been trying to reproduce this, unsuccessfully so far.\n\nI guess it depends on how exactly those files are \"part of the merge\",\nand how the merge driver is set up. (I've tried with and without recursive.)\n\nMichael\n"},{"id":"257159","messageId":"D8780C527EB1E642B3150E6D705B46D448E8058B@DWPWHMS531.dwpbank.local","threadId":"38707","inReplyTo":"54F98EBE.8080903@drmicha.warpmail.net","subject":"AW: Git merge driver / attributes bug in 2.3.1?","fromName":"Gondek, Andreas","fromEmail":"andreas.gondek@dwpbank.de","sentAt":"2015-03-06T13:31:52Z","receivedAt":"2015-03-06T13:31:52Z","isPatch":false,"sender":{"key":"andreas.gondek@dwpbank.de","avatar":null},"body":"The archive contains my test repository, the merge driver and the .gitconfig of the user. We don't have a global .gitconfig.\n\nMit freundlichen Grüßen\n\nAndreas Gondek\nApplications\n________________________________\n\nDeutsche WertpapierService Bank AG\nITTAS\nDerendorfer Allee 2\n40476 Düsseldorf\nTel.: +49 69 5099 9503\nFax: +49 69 5099 85 9503\nE-Mail: Andreas.Gondek@dwpbank.de\nhttp://www.dwpbank.de\n\nDeutsche WertpapierService Bank AG | Wildunger Straße 14 | 60487 Frankfurt am Main \nSitz der AG: Frankfurt am Main, HRB 56913 | USt.-ID: DE 813759005 \nVorstand: Thomas Klanten, Dr. Christian Tonnesen\nAufsichtsrat: Wilfried Groos (Vors.)\n-----Ursprüngliche Nachricht-----\nVon: Michael J Gruber [mailto:git@drmicha.warpmail.net] \nGesendet: Freitag, 6. März 2015 12:26\nAn: Gondek, Andreas; git@vger.kernel.org\nBetreff: Re: Git merge driver / attributes bug in 2.3.1?\n\nGondek, Andreas venit, vidit, dixit 05.03.2015 14:30:\n> Hello,\n> \n> after upgrading the Git installation on one of our development servers \n> from 1.9.0-rc3 to 2.3.1 we are experiencing strange behavior of merge \n> drivers.\n> \n> A merge driver registered as \"* merge=<name_of_merge_driver>\" in the \n> .gitattributes is now executed even if there isn't any merge conflict. \n> This only happens for files that are part of the merge.\n> \n> This is reproducible in test repositories.\n\nCan you share a minimal test repo?\n\nI've been trying to reproduce this, unsuccessfully so far.\n\nI guess it depends on how exactly those files are \"part of the merge\", and how the merge driver is set up. (I've tried with and without recursive.)\n\nMichael\n"},{"id":"257162","messageId":"54F9B5C0.9050604@drmicha.warpmail.net","threadId":"38707","inReplyTo":"D8780C527EB1E642B3150E6D705B46D448E8058B@DWPWHMS531.dwpbank.local","subject":"Re: Git merge driver / attributes bug in 2.3.1?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-06T14:12:16Z","receivedAt":"2015-03-06T14:12:16Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Gondek, Andreas venit, vidit, dixit 06.03.2015 14:31:\n> The archive contains my test repository, the merge driver and the .gitconfig of the user. We don't have a global .gitconfig.\n\nThanks for the test repo!\n\nAlas, the merge driver gets executed with v1.9.0-rc3, v1.8.5 and v1.7.0,\nat least over here - as it should be because of the conflict: two\npatches changing the same file. That conflict can be resolved\nautomatically by the internal driver, of course. Maybe something else\nchanged during the upgrade?\n\nMichael\n"},{"id":"257199","messageId":"xmqqlhj9yftb.fsf@gitster.dls.corp.google.com","threadId":"38707","inReplyTo":"54F9B5C0.9050604@drmicha.warpmail.net","subject":"Re: Git merge driver / attributes bug in 2.3.1?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-06T21:30:24Z","receivedAt":"2015-03-06T21:30:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Gondek, Andreas venit, vidit, dixit 06.03.2015 14:31:\n>> The archive contains my test repository, the merge driver and the\n> .gitconfig of the user. We don't have a global .gitconfig.\n>\n> Thanks for the test repo!\n>\n> Alas, the merge driver gets executed with v1.9.0-rc3, v1.8.5 and v1.7.0,\n> at least over here - as it should be because of the conflict: two\n> patches changing the same file. That conflict can be resolved\n> automatically by the internal driver, of course.\n\nThat matches my expectation.  The whole point to have the merge\ndriver plug-in mechanism is to allow overriding the internal textual\n3-way file-level merge, so we would have always called out to the\ncustom driver when the tree-level merge machinery says that the\ncontent needs a file-level merge [*1*].\n\n\n[Footnote]\n\n*1* This is a tangent, but I've been wondering if we want some cases\nwhere the tree-level merge machinery currently says that there is no\nneed for file-level merge to be fed to the merge driver.\n\nSpecifically, the tree-level merge machinery considers a case where\nyou and the other party changed the files identically to be cleanly\nmerged, but for contents of certain nature, that may not be always\ndesirable.\n\nImagine that I and my wife are sharing a note to record what is in\nour refrigerator.  After I buy a carton of milk, I'd do\n\n    $ echo \"1 carton of milk\" >>fridge.txt\n    $ git commit && git push\n\nand my wife would do the same.\n\n    $ echo \"1 carton of milk\" >>fridge.txt\n    $ git commit && git push\n\nwhich would not fast-forward, and then she would\n\n    $ git pull\n\nwhich would result in only one carton of milk in our fridge, even\nthough when both of us got home, we will realize that we now have\ntwo of them.\n"},{"id":"257371","messageId":"D8780C527EB1E642B3150E6D705B46D448E8063B@DWPWHMS531.dwpbank.local","threadId":"38707","inReplyTo":"xmqqlhj9yftb.fsf@gitster.dls.corp.google.com","subject":"AW: Git merge driver / attributes bug in 2.3.1?","fromName":"Gondek, Andreas","fromEmail":"andreas.gondek@dwpbank.de","sentAt":"2015-03-09T09:02:31Z","receivedAt":"2015-03-09T09:02:31Z","isPatch":false,"sender":{"key":"andreas.gondek@dwpbank.de","avatar":null},"body":"We used a merge driver to create a conflict semaphore file whenever a merge conflict occurs in Atlassian Stash. This worked for several month until we got to update our Git version because of another problem.\n\nIf I understand it correctly, a merge driver is executed before the normal internal merge happens? So I would need to call a git merge-file in my merge driver, test the result and return the exit code of the git merge-file?\n\nGreetings\n\nAndreas Gondek\nApplications\n________________________________\n\nDeutsche WertpapierService Bank AG\nITTAS\nDerendorfer Allee 2\n40476 Düsseldorf\nTel.: +49 69 5099 9503\nFax: +49 69 5099 85 9503\nE-Mail: Andreas.Gondek@dwpbank.de\nhttp://www.dwpbank.de\n\nDeutsche WertpapierService Bank AG | Wildunger Straße 14 | 60487 Frankfurt am Main \nSitz der AG: Frankfurt am Main, HRB 56913 | USt.-ID: DE 813759005 \nVorstand: Thomas Klanten, Dr. Christian Tonnesen\nAufsichtsrat: Wilfried Groos (Vors.)\n\n-----Ursprüngliche Nachricht-----\nVon: Junio C Hamano [mailto:gitster@pobox.com] \nGesendet: Freitag, 6. März 2015 22:30\nAn: Michael J Gruber\nCc: Gondek, Andreas; git@vger.kernel.org\nBetreff: Re: Git merge driver / attributes bug in 2.3.1?\n\nMichael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Gondek, Andreas venit, vidit, dixit 06.03.2015 14:31:\n>> The archive contains my test repository, the merge driver and the\n> .gitconfig of the user. We don't have a global .gitconfig.\n>\n> Thanks for the test repo!\n>\n> Alas, the merge driver gets executed with v1.9.0-rc3, v1.8.5 and \n> v1.7.0, at least over here - as it should be because of the conflict: \n> two patches changing the same file. That conflict can be resolved \n> automatically by the internal driver, of course.\n\nThat matches my expectation.  The whole point to have the merge driver plug-in mechanism is to allow overriding the internal textual 3-way file-level merge, so we would have always called out to the custom driver when the tree-level merge machinery says that the content needs a file-level merge [*1*].\n\n\n[Footnote]\n\n*1* This is a tangent, but I've been wondering if we want some cases where the tree-level merge machinery currently says that there is no need for file-level merge to be fed to the merge driver.\n\nSpecifically, the tree-level merge machinery considers a case where you and the other party changed the files identically to be cleanly merged, but for contents of certain nature, that may not be always desirable.\n\nImagine that I and my wife are sharing a note to record what is in our refrigerator.  After I buy a carton of milk, I'd do\n\n    $ echo \"1 carton of milk\" >>fridge.txt\n    $ git commit && git push\n\nand my wife would do the same.\n\n    $ echo \"1 carton of milk\" >>fridge.txt\n    $ git commit && git push\n\nwhich would not fast-forward, and then she would\n\n    $ git pull\n\nwhich would result in only one carton of milk in our fridge, even though when both of us got home, we will realize that we now have two of them.\n"},{"id":"257373","messageId":"54FD6953.9030406@drmicha.warpmail.net","threadId":"38707","inReplyTo":"D8780C527EB1E642B3150E6D705B46D448E8063B@DWPWHMS531.dwpbank.local","subject":"Re: Git merge driver / attributes bug in 2.3.1?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-09T09:35:15Z","receivedAt":"2015-03-09T09:35:15Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Gondek, Andreas venit, vidit, dixit 09.03.2015 10:02:\n> We used a merge driver to create a conflict semaphore file whenever a\n> merge conflict occurs in Atlassian Stash. This worked for several\n> month until we got to update our Git version because of another\n> problem.\n\nThat is the first issue: Can you reproduce with an older Git and your\ntest repo the effect that you wanted to achieve?\n\nI have tried a few older Git's with your test repo, and I always get the\nsame behavior as with current Git (and as we would expect). So,\nsomething else has to be going on here.\n\n> If I understand it correctly, a merge driver is executed before the\n> normal internal merge happens? So I would need to call a git\n> merge-file in my merge driver, test the result and return the exit\n> code of the git merge-file?\n\nFirst, the tree level merge checks whether the two sides introduce\ndifferent changes to the same files. If not a simple tree level merge is\ndone (which may or may not be OK, see Junio's shopping list example).\n\nIf yes (different changes to the same files), a merge driver is used,\neither an external one if specified, or the internal 3-way merge driver.\nBut I'm not a merge expert ;)\n\nIf I understand correctly, you want to use the external merge driver to\nsignal a conflict that git may miss otherwise?\n\nOn a side note, this discussion and the shopping list example show how\nbadly a tool like git-dep(endency) can go wrong, just like the automatic\nmerge. Just imagine a library change on one branch, and the introduction\nof a new call site following the old library calling convention on\nanother branch. No dependency detected, clean tree-level merge by git,\nand fails to compile (hopefully) or run (worse). Automatic mergers can\nonly guess, they are no code analyzers.\n\nMichael\n"}]}