{"thread":{"id":"66256","subject":"Inconsistency in commit message handling","startedAt":"2026-09-02T14:04:53Z","lastAt":"2026-09-02T14:04:53Z","messageCount":1,"participants":["Simon Cheng"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"551770","messageId":"CA+itcS2ViLXMdXHFZpNah=jnEBc3sf-Zympb_f0GzftN99Lppw@mail.gmail.com","threadId":"66256","inReplyTo":null,"subject":"Inconsistency in commit message handling","fromName":"Simon Cheng","fromEmail":"cyqsimon@gmail.com","sentAt":"2026-09-02T14:04:37Z","receivedAt":"2026-09-02T14:04:53Z","isPatch":false,"body":"When creating a normal commit using `git commit -m MSG`, an additional `\\n` is\nappended to the end of `MSG` before going through cleanup. However when creating\na merge commit using `git merge --no-ff -m MSG BRANCH`, this additional `\\n`\nappears to be missing.\n\nUnder default configuration this has no impact because `commit.cleanup\n= default`\nis equivalent to `commit.cleanup = whitespace` when non-interactive. Therefore\nthe additional `\\n` simply gets cleaned up and nothing happens.\n\nHowever in my case it does cause some trouble. I use the\n`prepare-commit-msg` hook to\ninject some comments into my editor to help me write during interactive commits.\nThis is the hook, with all irrelevant fluff removed:\n\n```\n#!/usr/bin/env bash\nCOMMIT_MSG_FILE=$1\necho \"# My additional comments\" >> \"$COMMIT_MSG_FILE\"\n```\n\nI also set `commit.cleanup = strip` so that these comments also get\ncleaned up for\nnon-interactive commits.\n\nAnd this works for normal commits interactive, normal commits non-interactive,\nmerge commits interactive, but NOT merge commits non-interactive.\nSince `git merge --no-ff -m MSG BRANCH` does not append a `\\n`, these comments\nactually clobber merge commits. `git merge --no-ff -m \"Merge message\"\nBRANCH` ends up\nhaving a message like this: \"Merge message# My additional comments\".\n\nI hesitate to call this a bug because arguably it's just some behaviour quirks\nthat my hook script should handle. But I think it is fair to call this\ninconsistent,\nand it creates surprises for the user as it did for me. I would prefer\nthat `git merge`\nadds this `\\n` too.\n\n---\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\n1. Add the aforementioned `prepare-commit-msg` hook.\n2. Set `commit.cleanup = strip`.\n3. Run `git merge --no-ff -m \"Merge message\" BRANCH`.\n4. Run `git show`\n\nWhat did you expect to happen? (Expected behavior)\n\nThe merge commit has message \"Merge message\".\n\nWhat happened instead? (Actual behavior)\n\nThe merge commit has message \"Merge message# My additional comments\".\n\nWhat's different between what you expected and what actually happened?\n\nMy injected comments did not appear on a new line, and hence failed to\nget cleaned up.\n\n\n[System Info]\ngit version:\ngit version 2.55.0\ncpu: x86_64\nbuilt from commit: e9019fcafe0040228b8631c30f97ae1adb61bcdc\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nrust: enabled\nfeature: fsmonitor--daemon\ngettext: enabled\nlibcurl: 8.21.0\nOpenSSL: OpenSSL 3.6.3 9 Jun 2026\nzlib-ng: 2.3.3\nSHA-1: SHA1_DC\nSHA-256: SHA256_BLK\ndefault-ref-format: files\ndefault-hash: sha1\nuname: Linux 6.18.48-1-lts #1 SMP PREEMPT_DYNAMIC Fri, 28 Aug 2026\n11:47:30 +0000 x86_64\ncompiler info: gnuc: 16.1\nlibc info: glibc: 2.44\n$SHELL (typically, interactive shell): /usr/bin/bash\n\n\n[Enabled Hooks]\nprepare-commit-msg\n"}]}