{"thread":{"id":"23158","subject":"force \"unmerged\" for same-file auto-merges","startedAt":"2010-03-24T01:44:05Z","lastAt":"2010-03-27T17:22:25Z","messageCount":5,"participants":["Neal Kreitzinger","Junio C Hamano","Sitaram Chamarty","Dilip M"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"137681","messageId":"hobqoc$5h3$1@dough.gmane.org","threadId":"23158","inReplyTo":null,"subject":"force \"unmerged\" for same-file auto-merges","fromName":"Neal Kreitzinger","fromEmail":"neal@rsss.com","sentAt":"2010-03-24T01:44:05Z","receivedAt":"2010-03-24T01:44:05Z","isPatch":false,"sender":{"key":"neal@rsss.com","avatar":null},"body":"Scenario:  \"same-file auto-merge\":  when two different people change the \nsame file in their separate repos.  Their changes do not conflict in the \nsense that they are changes to the same lines.  However, their changes do \nconflict in the sense that the resulting merged logic is incorrect.\n\nConcern:\nThe same-file auto-merge results are overlooked (not reviewed) by the \nprogrammer because there is nothing preventing a git-commit immediately \nafter the auto-merge completes.\n\nDesired Solution:\nPerform same-file auto-merge and produce auto-merge results, but mark all \nsuch auto-merged files as \"unmerged\" so that they must be reviewed/resolved \nbefore a git-commit.  The \"unmerged\" status allows git-mergetool to be run \n(e.g. kdiff3) so that the merged lines can be reviewed.  In this way, all \nauto-merged files are reviewed.\n\nDoes anyone know if there are configuration and/or command-line options in \ngit that can accomplish this in a fairly straightforward manner?  For \nexample, something like this:\n\n\nExample config:\n$ cat gitconfig\n[merge]\n            samefileauto = forceconflict\n\n\nExample command:\n$ git merge -s sameautoforceconflict branchx\n\n\nExample results:\n$ git merge -s sameautoforceconflict branchx\nMerging:\n11a99zz examplecommitb\nvirtual branchx\nfound 1 common ancestor(s):\n22b88yy examplecommita\nAuto-merging examplepgm\nMerge made by recursive.\n examplepgm |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n$git status\nexamplepgm: needs merge\n# On branch branchx\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working \ndirectory)\n#\n#       unmerged:   examplepgm\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n\nv/r,\nNeal \n"},{"id":"137821","messageId":"hoh16f$koe$1@dough.gmane.org","threadId":"23158","inReplyTo":"hobqoc$5h3$1@dough.gmane.org","subject":"Re: force \"unmerged\" for same-file auto-merges","fromName":"Neal Kreitzinger","fromEmail":"neal@rsss.com","sentAt":"2010-03-26T01:04:11Z","receivedAt":"2010-03-26T01:04:11Z","isPatch":false,"sender":{"key":"neal@rsss.com","avatar":null},"body":"In other words, when two people modify the same file in different places I \nwant the automerge results file, but I want the resulting file marked as \nunmerged so the programmer can then run git-mergetool to review the merge \nresults.  This also prevents the programmer from running git-commit \nimmediately after the automerge without reviewing the merge results.  Can \n\"mark automerge of samefile as 'unmerged'\" be done in git via config \nsettings or command options?\n\n\n\nv/r,\n\nNeal\n\n\n\n\"Neal Kreitzinger\" <neal@rsss.com> wrote in message \nnews:hobqoc$5h3$1@dough.gmane.org...\n> Scenario:  \"same-file auto-merge\":  when two different people change the \n> same file in their separate repos.  Their changes do not conflict in the \n> sense that they are changes to the same lines.  However, their changes do \n> conflict in the sense that the resulting merged logic is incorrect.\n>\n> Concern:\n> The same-file auto-merge results are overlooked (not reviewed) by the \n> programmer because there is nothing preventing a git-commit immediately \n> after the auto-merge completes.\n>\n> Desired Solution:\n> Perform same-file auto-merge and produce auto-merge results, but mark all \n> such auto-merged files as \"unmerged\" so that they must be \n> reviewed/resolved before a git-commit.  The \"unmerged\" status allows \n> git-mergetool to be run (e.g. kdiff3) so that the merged lines can be \n> reviewed.  In this way, all auto-merged files are reviewed.\n>\n> Does anyone know if there are configuration and/or command-line options in \n> git that can accomplish this in a fairly straightforward manner?  For \n> example, something like this:\n>\n>\n> Example config:\n> $ cat gitconfig\n> [merge]\n>            samefileauto = forceconflict\n>\n>\n> Example command:\n> $ git merge -s sameautoforceconflict branchx\n>\n>\n> Example results:\n> $ git merge -s sameautoforceconflict branchx\n> Merging:\n> 11a99zz examplecommitb\n> virtual branchx\n> found 1 common ancestor(s):\n> 22b88yy examplecommita\n> Auto-merging examplepgm\n> Merge made by recursive.\n> examplepgm |    2 +-\n> 1 files changed, 1 insertions(+), 1 deletions(-)\n> $git status\n> examplepgm: needs merge\n> # On branch branchx\n> # Changed but not updated:\n> #   (use \"git add <file>...\" to update what will be committed)\n> #   (use \"git checkout -- <file>...\" to discard changes in working \n> directory)\n> #\n> #       unmerged:   examplepgm\n> #\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n>\n>\n> v/r,\n> Neal\n>\n> \n"},{"id":"137883","messageId":"7vtys2lw4z.fsf@alter.siamese.dyndns.org","threadId":"23158","inReplyTo":"hobqoc$5h3$1@dough.gmane.org","subject":"Re: force \"unmerged\" for same-file auto-merges","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-26T19:29:16Z","receivedAt":"2010-03-26T19:29:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Neal Kreitzinger\" <neal@rsss.com> writes:\n\n> Does anyone know if there are configuration and/or command-line options in \n> git that can accomplish this in a fairly straightforward manner?\n\nI know there isn't.\n\nEssentially what you are asking for is\n\n    read-tree -m -u --trivial O A B\n\nfollowed by no file-level automerge.  I think you can write a custom merge\nstrategy, perhaps using \"resolve\" as a template, to do that.\n\nIn practice, you will get too many false \"conflicts\" with such a strategy\nand the quality of your \"review\" would degrade from fatigue, I suspect.\n"},{"id":"137938","messageId":"2e24e5b91003270156r11ae9155s6e00a2ab27e9f479@mail.gmail.com","threadId":"23158","inReplyTo":"hobqoc$5h3$1@dough.gmane.org","subject":"Re: force \"unmerged\" for same-file auto-merges","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2010-03-27T08:56:59Z","receivedAt":"2010-03-27T08:56:59Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On Wed, Mar 24, 2010 at 7:14 AM, Neal Kreitzinger <neal@rsss.com> wrote:\n> Scenario:  \"same-file auto-merge\":  when two different people change the\n> same file in their separate repos.  Their changes do not conflict in the\n> sense that they are changes to the same lines.  However, their changes do\n> conflict in the sense that the resulting merged logic is incorrect.\n\nYou're not being pessimistic enough :-)  A \".h\" file that changed only\non one side can cause the same logic issues\n\n> Desired Solution:\n> Perform same-file auto-merge and produce auto-merge results, but mark all\n> such auto-merged files as \"unmerged\" so that they must be reviewed/resolved\n> before a git-commit.  The \"unmerged\" status allows git-mergetool to be run\n> (e.g. kdiff3) so that the merged lines can be reviewed.  In this way, all\n> auto-merged files are reviewed.\n\nNo.  What you need is a full blown diff for the merge, with both sides\nbeing compared with respect to the common merge-base.  That diff will\nbe pretty big, although I'm not sure what diff options would actually\nproduce that (but I'll bet \"-m\" figures somewhere).\n"},{"id":"137956","messageId":"c94f8e121003271022v2b30ef52j3bd4015f12938f7a@mail.gmail.com","threadId":"23158","inReplyTo":"hoh16f$koe$1@dough.gmane.org","subject":"Re: force \"unmerged\" for same-file auto-merges","fromName":"Dilip M","fromEmail":"dilipm79@gmail.com","sentAt":"2010-03-27T17:22:25Z","receivedAt":"2010-03-27T17:22:25Z","isPatch":false,"sender":{"key":"dilipm79@gmail.com","avatar":"https://gravatar.com/avatar/9417e308513ce9251de2802a026c72eb164e6c9b9d7143a3ee13f6ed0c4d1bd5?d=mp&s=160"},"body":"On Fri, Mar 26, 2010 at 6:34 AM, Neal Kreitzinger <neal@rsss.com> wrote:\n\n> In other words, when two people modify the same file in different places I\n> want the automerge results file, but I want the resulting file marked as\n> unmerged so the programmer can then run git-mergetool to review the merge\n> results.  This also prevents the programmer from running git-commit\n> immediately after the automerge without reviewing the merge results.  Can\n> \"mark automerge of samefile as 'unmerged'\" be done in git via config\n> settings or command options?\n\nWhat about merge with '--no-commit' option and than doing 'diff --cached'. You\nhave option of still seeing what merged and decide to reset or commit.\n\n-- \nDilip\n"}]}