{"thread":{"id":"62603","subject":"Proposal: Allow Customization of Git Merge Commit Message Template","startedAt":"2024-12-05T17:01:00Z","lastAt":"2024-12-05T23:16:55Z","messageCount":2,"participants":["dangling .","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"508673","messageId":"DM4PR14MB4880061D71993B749F44F2EDA7302@DM4PR14MB4880.namprd14.prod.outlook.com","threadId":"62603","inReplyTo":null,"subject":"Proposal: Allow Customization of Git Merge Commit Message Template","fromName":"dangling .","fromEmail":"kasperkantz@outlook.com","sentAt":"2024-12-05T17:00:56Z","receivedAt":"2024-12-05T17:01:00Z","isPatch":false,"sender":{"key":"kasperkantz@outlook.com","avatar":null},"body":"Hello Git mailing list,\n\nI’d like to propose a feature to allow users to modify the default merge commit message template generated by `git merge`. Currently, when running:\n\n```\ngit merge --no-ff upstream/main\n```\n\nGit produces a message like:\n```sh\nMerge remote-tracking branch 'upstream/main' into my-branch\n```\n\nWhile informative, this message can be verbose and sometimes makes branch names difficult to fit within the recommended 52-character first line. Personally, I find a simplified format like this more concise and effective:\n```sh\nMerge upstream/main into my-branch\n```\n\nProposal:\nIntroduce an option (e.g., a configuration setting or CLI flag) that allows users to specify a custom merge commit message template. For example:\n\n- A new configuration option:\n  ```sh\n  [merge]\n      messageTemplate = \"Merge %s into %s\"\n  ```\n  Here, `%s` placeholders could represent the source and destination branches, respectively.\n\n- Alternatively, a command-line flag:\n  ```sh\n  git merge --message-template=\"Merge %s into %s\" upstream/main\n  ```\n\nLooking forward to your thoughts.\n\n/k"},{"id":"508695","messageId":"Z1I0XzE6QWlsyZkH@tapette.crustytoothpaste.net","threadId":"62603","inReplyTo":"DM4PR14MB4880061D71993B749F44F2EDA7302@DM4PR14MB4880.namprd14.prod.outlook.com","subject":"Re: Proposal: Allow Customization of Git Merge Commit Message Template","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2024-12-05T23:16:47Z","receivedAt":"2024-12-05T23:16:55Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2024-12-05 at 17:00:56, dangling . wrote:\n> Proposal:\n> Introduce an option (e.g., a configuration setting or CLI flag) that allows users to specify a custom merge commit message template. For example:\n> \n> - A new configuration option:\n>   ```sh\n>   [merge]\n>       messageTemplate = \"Merge %s into %s\"\n>   ```\n>   Here, `%s` placeholders could represent the source and destination branches, respectively.\n\nI think in general that such an option would need multiple placeholders.\nJust because in English we place the name of the second head before the\nname of the first head does not mean that that is true in all languages\nor translations.\n\n> - Alternatively, a command-line flag:\n>   ```sh\n>   git merge --message-template=\"Merge %s into %s\" upstream/main\n>   ```\n\nI think this can be done more generally with a `prepare-commit-msg`\nhook:\n\n----\n#!/bin/sh\n\nCOMMIT_MSG_FILE=$1\nCOMMIT_SOURCE=$2\n\ncase \"$COMMIT_SOURCE\" in\n merge)\n   /usr/bin/perl -i.bak -pe '\n   s/Merge remote-tracking branch '\\''(.*)'\\''/Merge $1/\n   ' \"$COMMIT_MSG_FILE\"\n   ;;\n *) ;;\nesac\n----\n\nThat's the approach we would generally recommend here, since it's more\nflexible and allows you more customization over the message.  Of course,\nyou can use sed or Ruby instead (or even ed or ex) if you prefer.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"}]}