git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[Bug] commit cleanup does not happen during autosquash rebase

From
SCSimon Cheng <cyqsimon@gmail.com>
Date
Aug 13, 2025, 11:39 UTC
Message-ID
<CA+itcS3DxbgpFy2aPRvHQvTAYE=dU0kfeDdidVwWLU=rBAWR4w@mail.gmail.com>

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
1. Initialize a git repo with `git init`
2. Install a custom `prepare-commit-msg` hook that injects some comments
  - Intention: inject the output of `git log --oneline -n10` during
interactive commit, so I can see past commits
3. Run `git config commit.cleanup strip`
  - Intention: strip the injected comments too in non-interactive mode
(e.g. `git cherry-pick` & `git rebase`)
4. Run `touch foo && git add -A && git commit -m "Initial commit"`
5. Run `touch bar && git add -A && git commit --fixup=@`
6. Run `git rebase --root --autosquash`
What did you expect to happen? (Expected behavior)

Git would perform the autosquash, while keeping the commit message of the squash target unchanged.

What happened instead? (Actual behavior)

Git performed the autosquash, but the commit message of the squash target is now clobbered with my injected comments.

What's different between what you expected and what actually happened?

I expected commit cleanup to happen during the autosquash. It seems like that didn't happen.

Anything else you want to add:

Here is my `prepare-commit-msg` script. But I expect this issue to be replicable with anything that injects comments.

```
#!/usr/bin/env bash
{
  echo '# Last 10 commits:'
  git log --oneline -n 10 --decorate=short | sed 's/^/#   /'
  echo '#'
} >> "$1"
```

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.50.1
cpu: x86_64
built from commit: d82adb61ba2fd11d8f2587fca1b6bd7925ce4044
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.14.1
OpenSSL: OpenSSL 3.5.1 1 Jul 2025
zlib-ng: 2.2.4
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
uname: Linux 6.12.41-1-lts #1 SMP PREEMPT_DYNAMIC Fri, 01 Aug 2025
20:42:03 +0000 x86_64
compiler info: gnuc: 15.1
libc info: glibc: 2.42
$SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks] prepare-commit-msg

Next: Phillip Wood
Message 1 of 4 in “[Bug] commit cleanup does not happen during autosquash rebase”
  1. Simon ChengAug 13, 2025
  2. Phillip WoodAug 18, 2025
  3. Simon ChengSep 15, 2025
  4. Phillip WoodSep 18, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.