{"thread":{"id":"17404","subject":"How to install and use a custom merge driver","startedAt":"2009-01-28T03:10:18Z","lastAt":"2009-01-29T07:11:58Z","messageCount":9,"participants":["Alec Clews","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"102232","messageId":"497FCC9A.9080008@gmail.com","threadId":"17404","inReplyTo":null,"subject":"How to install and use a custom merge driver","fromName":"Alec Clews","fromEmail":"alec.clews@gmail.com","sentAt":"2009-01-28T03:10:18Z","receivedAt":"2009-01-28T03:10:18Z","isPatch":false,"sender":{"key":"alec.clews@gmail.com","avatar":null},"body":"Background:\n\nI want to use git to track the delivery of patch files into existing \nfile trees. This means that new files will need to be copied over \nexisting files (especially in the case of binary files or textual conflicts)\n\nTo this end I want to use a custom merge driver (actually the cp command)\n\nSetup:\n\nI have set up my ..git/info/gitattributes as follows\n\n*      merge=overwrite\n\nI have defined in .git/config\n\n[merge \"overwrite\"]\n    name = overwrite using cp\n    driver = cp %B %A\n\nProblem:\n\nHowever when I perform a git merge the default merge is being called. Is \nthere something else needed to make git perform the copy operation?\n\n\nMany thanks\n\n-- \nAlec Clews\nPersonal <alec.clews@gmail.com>\t\t\tMelbourne, Australia.\nJabber:  alecclews@jabber.org.au\t\tPGPKey ID: 0x9BBBFC7C\nBlog  http://alecthegeek.wordpress.com/\n"},{"id":"102255","messageId":"20090128061848.GA19165@coredump.intra.peff.net","threadId":"17404","inReplyTo":"497FCC9A.9080008@gmail.com","subject":"Re: How to install and use a custom merge driver","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-01-28T06:18:48Z","receivedAt":"2009-01-28T06:18:48Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jan 28, 2009 at 02:10:18PM +1100, Alec Clews wrote:\n\n> Setup:\n>\n> I have set up my ..git/info/gitattributes as follows\n>\n> *      merge=overwrite\n\nYour setup looks right, except that the correct file is\n\".git/info/attributes\".\n\n-Peff\n"},{"id":"102368","messageId":"loom.20090128T230123-889@post.gmane.org","threadId":"17404","inReplyTo":"20090128061848.GA19165@coredump.intra.peff.net","subject":"Re: How to install and use a custom merge driver","fromName":"Alec Clews","fromEmail":"alecclews@gmail.com","sentAt":"2009-01-28T23:04:02Z","receivedAt":"2009-01-28T23:04:02Z","isPatch":false,"sender":{"key":"alecclews@gmail.com","avatar":"https://gravatar.com/avatar/6678bf1bc5b4e4063f6a4bef1499e08eda6d08738eb5e8cce9981316490377d4?d=mp&s=160"},"body":"Jeff King <peff <at> peff.net> writes:\n> On Wed, Jan 28, 2009 at 02:10:18PM +1100, Alec Clews wrote:\n> \n> > Setup:\n> >\n> > I have set up my ..git/info/gitattributes as follows\n> >\n> > *      merge=overwrite\n> \n> Your setup looks right, except that the correct file is\n> \".git/info/attributes\".\n\nThanks Jeff\n\nI fixed that problem -- however it did not make any difference.\n\nIs there someway to enable logging to see how git is making this choice?\n\n- Alec\n"},{"id":"102372","messageId":"loom.20090128T232911-174@post.gmane.org","threadId":"17404","inReplyTo":"loom.20090128T230123-889@post.gmane.org","subject":"Re: How to install and use a custom merge driver","fromName":"Alec Clews","fromEmail":"alecclews@gmail.com","sentAt":"2009-01-28T23:31:30Z","receivedAt":"2009-01-28T23:31:30Z","isPatch":false,"sender":{"key":"alecclews@gmail.com","avatar":"https://gravatar.com/avatar/6678bf1bc5b4e4063f6a4bef1499e08eda6d08738eb5e8cce9981316490377d4?d=mp&s=160"},"body":"Alec Clews <alecclews <at> gmail.com> writes:\n\n> Is there someway to enable logging to see how git is making this choice?\n\n\nFound the answer to my question.\n\nGIT_MERGE_VERBOSITY=5\nGIT_TRACE=true\n\n\nWhich results in\n\n+ git merge --stat del2\ntrace: built-in: git 'merge' '--stat' 'del2'\nMerging:\n38f3eb9 Accepting delivery del1\nvirtual del2\nfound 1 common ancestor(s):\naf9dc93 Creating empty staging repo\nAuto-merging src/main.c\nCONFLICT (add/add): Merge conflict in src/main.c\nAutomatic merge failed; fix conflicts and then commit the result.\n\n\nSo I'm none the wiser :-(. Any suggestions from wiser people than I?\n\nThanks\n\n-Alec\n"},{"id":"102393","messageId":"20090129032531.GA11836@coredump.intra.peff.net","threadId":"17404","inReplyTo":"loom.20090128T230123-889@post.gmane.org","subject":"Re: How to install and use a custom merge driver","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-01-29T03:25:31Z","receivedAt":"2009-01-29T03:25:31Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jan 28, 2009 at 11:04:02PM +0000, Alec Clews wrote:\n\n> I fixed that problem -- however it did not make any difference.\n\nCan you post an exact recipe for recreating the problem? It works just\nfine here, using:\n\n-- >8 --\ncommit() {\n  echo $1 >file && git add file && git commit -m $1\n}\n\nmkdir repo && cd repo && git init\ncommit base\ncommit branch-master\ngit checkout -b other HEAD^\ncommit branch-other\n\necho '* merge=overwrite' >.git/info/attributes\ncat >>.git/config <<'EOF'\n[merge \"overwrite\"]\n  name = overwrite using cp\n  driver= cp %B %A\nEOF\n\ngit merge master\n-- 8< --\n\nI get an automatic merge with the contents from \"master\" (and without\nthe merge config, there is obviously a conflict).\n\n> Is there someway to enable logging to see how git is making this choice?\n\nYou can try \"git check-attr merge file\" to be sure that it is picking up\nthe attribute.\n\n-Peff\n"},{"id":"102403","messageId":"loom.20090129T044425-689@post.gmane.org","threadId":"17404","inReplyTo":"20090129032531.GA11836@coredump.intra.peff.net","subject":"Re: How to install and use a custom merge driver","fromName":"Alec Clews","fromEmail":"alecclews@gmail.com","sentAt":"2009-01-29T04:47:19Z","receivedAt":"2009-01-29T04:47:19Z","isPatch":false,"sender":{"key":"alecclews@gmail.com","avatar":"https://gravatar.com/avatar/6678bf1bc5b4e4063f6a4bef1499e08eda6d08738eb5e8cce9981316490377d4?d=mp&s=160"},"body":"Problem solved.\n\nIt appears that TAB is not supported as white space in either attributes or \nconfig files? I removed all the tabs and it works as described on the box\n\nMany many thanks for the help Jeff\n\n- Alec\n"},{"id":"102405","messageId":"20090129050348.GA31202@coredump.intra.peff.net","threadId":"17404","inReplyTo":"loom.20090129T044425-689@post.gmane.org","subject":"Re: How to install and use a custom merge driver","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-01-29T05:03:48Z","receivedAt":"2009-01-29T05:03:48Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jan 29, 2009 at 04:47:19AM +0000, Alec Clews wrote:\n\n> It appears that TAB is not supported as white space in either attributes or \n> config files? I removed all the tabs and it works as described on the box\n\nThat's odd. It should be fine. And if I repeat the test I posted with:\n\n  printf '*\\tmerge=overwrite\\n' >.git/info/attributes\n  (printf '[merge \"overwrite\"]\\n'\n   printf '\\tname = overwrite using cp\\n'\n   printf '\\tdriver = cp %%B %%A\\n'\n  ) >>.git/config\n\nit works as before.\n\nWhat git version are you using? Can you post a shell snippet that breaks\nreliably?\n\n-Peff\n"},{"id":"102411","messageId":"49815423.8000902@gmail.com","threadId":"17404","inReplyTo":"20090129050348.GA31202@coredump.intra.peff.net","subject":"Re: How to install and use a custom merge driver","fromName":"Alec Clews","fromEmail":"alec.clews@gmail.com","sentAt":"2009-01-29T07:00:51Z","receivedAt":"2009-01-29T07:00:51Z","isPatch":false,"sender":{"key":"alec.clews@gmail.com","avatar":null},"body":"Jeff King wrote:\n> On Thu, Jan 29, 2009 at 04:47:19AM +0000, Alec Clews wrote:\n>\n>   \n> What git version are you using? Can you post a shell snippet that breaks\n> reliably?\n>   \n\nI used 1.5.6.3 on Ubuntu and 1.6.1.1 on Cygwin.\n\nThe problem appears to be spaces around '=' in the attributes file. This \nfails for me\n\n\n----------8<----------------------------------\ncommit() {\n echo $1 >file && git add file && git commit -m $1\n}\n\nrm -rf repo\n\nmkdir repo && cd repo && git init\ncommit base\ncommit branch-master\ngit checkout -b other HEAD^\ncommit branch-other\n\necho '* merge = overwrite' >.git/info/attributes\ncat >>.git/config <<'EOF'\n[merge \"overwrite\"]\n name = overwrite using cp\n driver= cp %B %A\nEOF\n\ngit merge master\n----------8<---------------------------------\n\n\n\n-- \nAlec Clews\nPersonal <alec.clews@gmail.com>\t\t\tMelbourne, Australia.\nJabber:  alecclews@jabber.org.au\t\tPGPKey ID: 0x9BBBFC7C\nBlog  http://alecthegeek.wordpress.com/\n"},{"id":"102412","messageId":"20090129071158.GA554@coredump.intra.peff.net","threadId":"17404","inReplyTo":"49815423.8000902@gmail.com","subject":"Re: How to install and use a custom merge driver","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-01-29T07:11:58Z","receivedAt":"2009-01-29T07:11:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jan 29, 2009 at 06:00:51PM +1100, Alec Clews wrote:\n\n> The problem appears to be spaces around '=' in the attributes file. This  \n> fails for me\n> [...]\n> echo '* merge = overwrite' >.git/info/attributes\n\nAh, OK. That isn't supposed to work. The attributes are whitespace\nseparated, and some don't even have an equals at all (e.g., \"merge\",\n\"-merge\", and \"merge=foo\" are all valid). So that parses to \"please use\nthe ordinary text merge driver\", and some attributes that nobody uses\ncalled \"=\" and \"overwrite\".\n\n-Peff\n"}]}