{"thread":{"id":"13786","subject":"How do I control the automated commit message on a merge?","startedAt":"2008-06-03T21:55:10Z","lastAt":"2008-06-04T07:33:17Z","messageCount":4,"participants":["Marvin Fraeman","Johannes Schindelin","Stephan Beyer"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"78557","messageId":"bd2cb52a0806031455r151303achf0424b5320bf2f07@mail.gmail.com","threadId":"13786","inReplyTo":null,"subject":"How do I control the automated commit message on a merge?","fromName":"Marvin Fraeman","fromEmail":"marvin.fraeman@gmail.com","sentAt":"2008-06-03T21:55:10Z","receivedAt":"2008-06-03T21:55:10Z","isPatch":false,"sender":{"key":"marvin.fraeman@gmail.com","avatar":null},"body":"I am using git-svn. The SVN repository I'm dealing with has a standard\ncomment convention I must follow. It is a simple static string of\ninformation that must appear on the first line of the commit message.\nEverything else can be free-form.\n\nI figured out how to add a commit template to my gitconfig file. So\nfor regular commits, I think I'm fine. But when Git does a merge (no\nconflicts), it auto-generates a commit message like:\n\n        Merge branch 'master' of  /path/to/other/repo\n\nHow can I change this so my required string gets written at the\nbeginning of the commit message. I played with the commit-msg and\nprepare-commit-msg hooks, but it didn't seem to get triggered in the\nmerge case.\n\nAlso, having the prepare-commit-msg hook add text had the side-effect\nthat in my normal commits, the message was always accepted, even when\nI wanted to abort (vi using :q!). In case I ever do need to use\nprepare-commit-msg, is there a way I can use it where abort still can\nwork?\n\n\nThank you\n"},{"id":"78564","messageId":"alpine.DEB.1.00.0806032350170.13507@racer.site.net","threadId":"13786","inReplyTo":"bd2cb52a0806031455r151303achf0424b5320bf2f07@mail.gmail.com","subject":"Re: How do I control the automated commit message on a merge?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-03T22:51:24Z","receivedAt":"2008-06-03T22:51:24Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 3 Jun 2008, Marvin Fraeman wrote:\n\n> when Git does a merge (no conflicts), it auto-generates a commit message \n> like:\n> \n>         Merge branch 'master' of  /path/to/other/repo\n> \n> How can I change this so my required string gets written at the\n> beginning of the commit message.\n\ns/./?/\n\nYou might be happy with a post-merge hook amending the commit with a \ncompletely different message.\n\nHth,\nDscho\n"},{"id":"78574","messageId":"bd2cb52a0806031705x7cc153bsc00e1a0198d6e7b5@mail.gmail.com","threadId":"13786","inReplyTo":"alpine.DEB.1.00.0806032350170.13507@racer.site.net","subject":"Re: How do I control the automated commit message on a merge?","fromName":"Marvin Fraeman","fromEmail":"marvin.fraeman@gmail.com","sentAt":"2008-06-04T00:05:43Z","receivedAt":"2008-06-04T00:05:43Z","isPatch":false,"sender":{"key":"marvin.fraeman@gmail.com","avatar":null},"body":"On Tue, Jun 3, 2008 at 3:51 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Tue, 3 Jun 2008, Marvin Fraeman wrote:\n>\n>> when Git does a merge (no conflicts), it auto-generates a commit message\n>> like:\n>>\n>>         Merge branch 'master' of  /path/to/other/repo\n>>\n>> How can I change this so my required string gets written at the\n>> beginning of the commit message.\n>\n> s/./?/\n\nWhere do I do the substitution in this case? I don't know where this\ndefault commit message is coming from and where to intercept it. Are\nyou saying this is part of the post-merge hook or is that an\nalternative solution?\n\nThank you\n"},{"id":"78594","messageId":"20080604073317.GA7752@leksak.fem-net","threadId":"13786","inReplyTo":"bd2cb52a0806031705x7cc153bsc00e1a0198d6e7b5@mail.gmail.com","subject":"Re: How do I control the automated commit message on a merge?","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-06-04T07:33:17Z","receivedAt":"2008-06-04T07:33:17Z","isPatch":false,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\n> >> when Git does a merge (no conflicts), it auto-generates a commit message\n> >> like:\n> >>\n> >>         Merge branch 'master' of  /path/to/other/repo\n> >>\n> >> How can I change this so my required string gets written at the\n> >> beginning of the commit message.\n> >\n> > s/./?/\n> \n> Where do I do the substitution in this case?\n\nIn the question that you sent to the list ;-)\n(But something like s/\\./?/ makes more sense.)\n\nThe real answer of Johannes to your question was only:\n> You might be happy with a post-merge hook amending the commit with a\n> completely different message.\n\nMeaning, you should put something like\n #!/bin/sh\n git commit -m \"This is my new commit message.\" --amend\nor better:\n #!/bin/sh\n git commit --amend -m \"$(git cat-file commit HEAD |\n \tsed -e '1,/^$/d;s/^/YOUR SIMPLE STATIC STRING HERE\\n\\n/')\"\ninto .git/hooks/post-merge (and make it executable).\nYOUR SIMPLE STATIC STRING HERE is the new first line.\nReplace the \\n\\n by a space to get someting like\n\"YOUR SIMPLE STATIC STRING HERE Merge foo into HEAD.\"\n\n> Also, having the prepare-commit-msg hook add text had the side-effect\n> that in my normal commits, the message was always accepted, even when\n> I wanted to abort (vi using :q!).\n\nLet the commit-msg hook add the text afterwards.\n\nOr remove the prepared commit message in vi and then press :x (or :wq),\nbecause commit aborts on an *empty* commit message and not on \nan unchanged commit message.\n\nRegards,\n  Stephan\n\n-- \nStephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F\n"}]}