{"thread":{"id":"29908","subject":"Trouble with file specific merge strategies","startedAt":"2012-03-10T23:47:41Z","lastAt":"2012-03-11T18:01:43Z","messageCount":7,"participants":["suvayu ali","Junio C Hamano","Thomas Hochstein"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"186638","messageId":"CAMXnza3SLHWLsFkYLhkJLAwtP2n=QVTXZ__GSL-CvajxC6i0Dw@mail.gmail.com","threadId":"29908","inReplyTo":null,"subject":"Trouble with file specific merge strategies","fromName":"suvayu ali","fromEmail":"fatkasuvayu+linux@gmail.com","sentAt":"2012-03-10T23:47:41Z","receivedAt":"2012-03-10T23:47:41Z","isPatch":false,"sender":{"key":"fatkasuvayu+linux@gmail.com","avatar":"https://gravatar.com/avatar/f1adf659f41e5846ddf6ab73bb474a3d9c29ac8ff8fa32adbf5796fc945096d0?d=mp&s=160"},"body":"Hi git devs,\n\nI have a repo with two branches where some files are absent in one of\nthe branches. Say the two branches are <allfiles> and <somefiles>. Until now\nI was using\n\n$ git merge -s ours <allfiles> # with <somefiles> checked out\n\nto merge commits which touches the absent files. But this clutters up\nhistory and is very inconvenient to do sometimes. So when I came across\nthe possibility of using .gitattributes for file specific merge\nstrategies, I tried the following:\n\npattern merge=ours\n\nHowever I get the following conflict message:\n\nCONFLICT (rename/delete): org-mode-config.el deleted in HEAD and\nrenamed in 74288bb. Version 74288bb of org-mode-config.el left in\ntree.\n\nThis file was deleted from <somefiles> in the past[1] and was renamed in\n<allfiles> since the last merge. I was expecting this file to be ignored\n(or in other words, merged with ours) since the .gitattributes file has\nentries like these:\n\norg-mode-config.el\t   merge=ours  # new name in allfiles branch\nlisp/org-mode-settings.el  merge=ours  # old name deleted in somefiles\n\nI also see other new files in <allfiles> which are mentioned in\n.gitattributes being merged in <somefiles>.\n\n$ git status -sb\n## somefiles\nM  abbrev_defs\nA  cpp-config.el\nA  email-config.el                 # <-- this should be ignored\nA  gui-config.el                   # <-- this should be ignored\nUU init.el\nA  keybindings.el\nM  lisp/skeletons.el\nD  lisp/text-mode-like-settings.el\nUA org-mode-config.el              # <-- this should be ignored\nA  text-mode-config.el\n\nWhat am I doing wrong here? My git version is 1.7.7.6.\n\nThanks in advance,\n\n\nFootnotes:\n\n[1] There has been several successful merges since then.\n\n-- \nSuvayu\n\nOpen source is the future. It sets us free.\n"},{"id":"186641","messageId":"7vk42rzfab.fsf@alter.siamese.dyndns.org","threadId":"29908","inReplyTo":"CAMXnza3SLHWLsFkYLhkJLAwtP2n=QVTXZ__GSL-CvajxC6i0Dw@mail.gmail.com","subject":"Re: Trouble with file specific merge strategies","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-11T08:57:00Z","receivedAt":"2012-03-11T08:57:00Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"suvayu ali <fatkasuvayu+linux@gmail.com> writes:\n\n> ... So when I came across\n> the possibility of using .gitattributes for file specific merge\n> strategies, I tried the following:\n>\n> pattern merge=ours\n\nI do not think we say .gitattributes can give merge strategy\nanywhere in our document.\n\nYou can choose one of the few built-in merge drivers but \"ours\" is\nnot one of them.  Have you defined your own merge driver \"ours\"\nfollowing the example in the gitattributes documentation (look for\n\"feel-free merge driver\")?\n"},{"id":"186643","messageId":"CAMXnza12HVFdmji7k-b-G43NWmobqCQEwXZXB=VxJA=tatqX-g@mail.gmail.com","threadId":"29908","inReplyTo":"7vk42rzfab.fsf@alter.siamese.dyndns.org","subject":"Re: Trouble with file specific merge strategies","fromName":"suvayu ali","fromEmail":"fatkasuvayu+linux@gmail.com","sentAt":"2012-03-11T10:10:19Z","receivedAt":"2012-03-11T10:10:19Z","isPatch":false,"sender":{"key":"fatkasuvayu+linux@gmail.com","avatar":"https://gravatar.com/avatar/f1adf659f41e5846ddf6ab73bb474a3d9c29ac8ff8fa32adbf5796fc945096d0?d=mp&s=160"},"body":"Hi Junio,\n\nOn Sun, Mar 11, 2012 at 09:57, Junio C Hamano <gitster@pobox.com> wrote:\n> suvayu ali <fatkasuvayu+linux@gmail.com> writes:\n>\n>> ... So when I came across\n>> the possibility of using .gitattributes for file specific merge\n>> strategies, I tried the following:\n>>\n>> pattern merge=ours\n>\n> I do not think we say .gitattributes can give merge strategy\n> anywhere in our document.\n>\n> You can choose one of the few built-in merge drivers but \"ours\" is\n> not one of them.  Have you defined your own merge driver \"ours\"\n> following the example in the gitattributes documentation (look for\n> \"feel-free merge driver\")?\n\nAh, that explains it. You are absolutely correct in saying that the\ndocs don't imply this. I was having doubts about this while reading the\ndocs (man gitattributes). I got confused by this[1] example on progit\nand several pointers to it on stackoverflow. And no, I don't have a\ncustom merge driver.\n\nThis brings up the question, is that discussion on progit talking about\nsomething else? Is there a way to setup file specific merge strategies\nin a repo?\n\nThanks a lot for your response. :)\n\nCheers,\n\nFootnotes:\n\n[1] http://progit.org/book/ch7-2.html#merge_strategies\n\n-- \nSuvayu\n\nOpen source is the future. It sets us free.\n"},{"id":"186651","messageId":"7vd38jxu5b.fsf@alter.siamese.dyndns.org","threadId":"29908","inReplyTo":"CAMXnza12HVFdmji7k-b-G43NWmobqCQEwXZXB=VxJA=tatqX-g@mail.gmail.com","subject":"Re: Trouble with file specific merge strategies","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-11T11:18:56Z","receivedAt":"2012-03-11T11:18:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"suvayu ali <fatkasuvayu+linux@gmail.com> writes:\n\n> ... is that discussion on progit talking about\n> something else?\n\nSorry, I do not read or write progit, so I do not know offhand what\nit says in the section you read and I cannot judge if it was you who\nmisread, or if it was book that misspoke.\n"},{"id":"186652","messageId":"CAMXnza2KeDB+=59jduBWc9_6xD0qaOXSx2psX0pYDY+LwqTX0w@mail.gmail.com","threadId":"29908","inReplyTo":"7vd38jxu5b.fsf@alter.siamese.dyndns.org","subject":"Re: Trouble with file specific merge strategies","fromName":"suvayu ali","fromEmail":"fatkasuvayu+linux@gmail.com","sentAt":"2012-03-11T11:27:55Z","receivedAt":"2012-03-11T11:27:55Z","isPatch":false,"sender":{"key":"fatkasuvayu+linux@gmail.com","avatar":"https://gravatar.com/avatar/f1adf659f41e5846ddf6ab73bb474a3d9c29ac8ff8fa32adbf5796fc945096d0?d=mp&s=160"},"body":"Hi Junio,\n\nOn Sun, Mar 11, 2012 at 12:18, Junio C Hamano <gitster@pobox.com> wrote:\n> suvayu ali <fatkasuvayu+linux@gmail.com> writes:\n>\n>> ... is that discussion on progit talking about\n>> something else?\n>\n> Sorry, I do not read or write progit, so I do not know offhand what\n> it says in the section you read and I cannot judge if it was you who\n> misread, or if it was book that misspoke.\n>\n\nOkay, thanks. I'll switch back to the tried and tested,\n\n$ git merge -s ours\n\nI'll take up the progit issue on the relevant discussion boards.\n\n-- \nSuvayu\n\nOpen source is the future. It sets us free.\n"},{"id":"186655","messageId":"gcvg.1203111617.379@landroval.ancalagon.de","threadId":"29908","inReplyTo":"7vd38jxu5b.fsf@alter.siamese.dyndns.org","subject":"Re: Trouble with file specific merge strategies","fromName":"Thomas Hochstein","fromEmail":"thh@inter.net","sentAt":"2012-03-11T15:17:52Z","receivedAt":"2012-03-11T15:17:52Z","isPatch":false,"sender":{"key":"thh@inter.net","avatar":"https://avatars.githubusercontent.com/u/365129?v=4"},"body":"Junio C Hamano wrote:\n\n> suvayu ali <fatkasuvayu+linux@gmail.com> writes:\n>\n>> ... is that discussion on progit talking about\n>> something else?\n>\n> Sorry, I do not read or write progit, so I do not know offhand what\n> it says in the section you read and I cannot judge if it was you who\n> misread, or if it was book that misspoke.\n\nThe book says:\n> You can also use Git attributes to tell Git to use different merge\n> strategies for specific files in your project. One very useful option\n> is to tell Git to not try to merge specific files when they have\n> conflicts, but rather to use your side of the merge over someone\n> else’s.\n>\n> This is helpful if a branch in your project has diverged or is\n> specialized, but you want to be able to merge changes back in from\n> it, and you want to ignore certain files. Say you have a database\n> settings file called database.xml that is different in two branches,\n> and you want to merge in your other branch without messing up the\n> database file. You can set up an attribute like this:\n>\n>| database.xml merge=ours\n>\n> If you merge in the other branch, instead of having merge conflicts\n> with the database.xml file, you see something like this:\n>\n>| $ git merge topic\n>| Auto-merging database.xml\n>| Merge made by recursive.\n>\n> In this case, database.xml stays at whatever version you originally had.\n\nThat seems to be incorrect, as far as I understand the gitattributes\nman page.\n\n-thh\n"},{"id":"186658","messageId":"CAMXnza2vD+XOstbNbt+wJgAGE7OEDpQTqGL8NWjWd0fYkWbJ2w@mail.gmail.com","threadId":"29908","inReplyTo":"gcvg.1203111617.379@landroval.ancalagon.de","subject":"Re: Trouble with file specific merge strategies","fromName":"suvayu ali","fromEmail":"fatkasuvayu+linux@gmail.com","sentAt":"2012-03-11T18:01:43Z","receivedAt":"2012-03-11T18:01:43Z","isPatch":false,"sender":{"key":"fatkasuvayu+linux@gmail.com","avatar":"https://gravatar.com/avatar/f1adf659f41e5846ddf6ab73bb474a3d9c29ac8ff8fa32adbf5796fc945096d0?d=mp&s=160"},"body":"Hello Thomas,\n\nOn Sun, Mar 11, 2012 at 16:17, Thomas Hochstein <thh@inter.net> wrote:\n> Junio C Hamano wrote:\n>\n>> suvayu ali <fatkasuvayu+linux@gmail.com> writes:\n>>\n>>> ... is that discussion on progit talking about\n>>> something else?\n>>\n>> Sorry, I do not read or write progit, so I do not know offhand what\n>> it says in the section you read and I cannot judge if it was you who\n>> misread, or if it was book that misspoke.\n>\n> The book says:\n>> You can also use Git attributes to tell Git to use different merge\n>> strategies for specific files in your project. One very useful option\n>> is to tell Git to not try to merge specific files when they have\n>> conflicts, but rather to use your side of the merge over someone\n>> else’s.\n>>\n>> This is helpful if a branch in your project has diverged or is\n>> specialized, but you want to be able to merge changes back in from\n>> it, and you want to ignore certain files. Say you have a database\n>> settings file called database.xml that is different in two branches,\n>> and you want to merge in your other branch without messing up the\n>> database file. You can set up an attribute like this:\n>>\n>>| database.xml merge=ours\n>>\n>> If you merge in the other branch, instead of having merge conflicts\n>> with the database.xml file, you see something like this:\n>>\n>>| $ git merge topic\n>>| Auto-merging database.xml\n>>| Merge made by recursive.\n>>\n>> In this case, database.xml stays at whatever version you originally had.\n>\n> That seems to be incorrect, as far as I understand the gitattributes\n> man page.\n>\n\nThank you for confirming the error. I have opened a ticket on the progit\nrepo on github. If you are interested, you can follow it on the page\nlinked below.\n\n<https://github.com/progit/progit.github.com/issues/5>\n\nCheers,\n\n-- \nSuvayu\n\nOpen source is the future. It sets us free.\n"}]}