# Config options -c in rebase --continue not passed to prepare-commit-msg hook

2 messages from 2025-09-04 to 2025-09-05. Participants: Devste Devste, Jeff King.
Thread: https://gitlist.dev/t/64089

## Devste Devste, 2025-09-04 12:46

Subject: Config options -c in rebase --continue not passed to prepare-commit-msg hook
Message-ID: <CANM0SV0+t7x_VTtZNCO8rKo1vvxhJjwEdmjLDN70njxCo7DofQ@mail.gmail.com>
URL: https://gitlist.dev/e/CANM0SV0%2Bt7x_VTtZNCO8rKo1vvxhJjwEdmjLDN70njxCo7DofQ%40mail.gmail.com

```
For some reason neither environment variables nor -c is passed to the
prepare-commit-msg hook when rebasing.
Other parameters (e.g. -C /path/to/repo) are passed correctly/it's
running the command in the correct repo

Reproduction:
1) Create a prepare-commit-msg hook with content
echo "prepare-commit-msg hook"
echo "$FOO"
git config --get hooks.foobar
exit 1

2) rebase a branch with conflicts. After resolving a conflict run:
FOO=bar git -c hooks.foobar=hello rebase --continue

The hook is executed but neither $FOO nor the config are set (both
echo an empty line)
Output:
prepare-commit-msg hook



Expected output:
prepare-commit-msg hook
bar
hello

Git 2.51.0

```

## Jeff King, 2025-09-05 21:23

Subject: Re: Config options -c in rebase --continue not passed to prepare-commit-msg hook
Message-ID: <20250905212321.GA612697@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20250905212321.GA612697%40coredump.intra.peff.net
In-Reply-To: <CANM0SV0+t7x_VTtZNCO8rKo1vvxhJjwEdmjLDN70njxCo7DofQ@mail.gmail.com>

```
On Thu, Sep 04, 2025 at 02:46:13PM +0200, Devste Devste wrote:

> For some reason neither environment variables nor -c is passed to the
> prepare-commit-msg hook when rebasing.
> Other parameters (e.g. -C /path/to/repo) are passed correctly/it's
> running the command in the correct repo

If the environment is being cleared, then that would explain "-c" as
well, since it passes through the environment. However, I can't
reproduce the problem here.

This is my full recipe:

-- >8 --
git init
git checkout main
echo base >file && git add file && git commit -m base
echo main >>file && git commit -am main
git checkout -b side HEAD^
echo side >>file && git commit -am side


cat >.git/hooks/prepare-commit-msg <<\EOF
#!/bin/sh
echo "in prepare-commit-msg hook"
echo "FOO: $FOO"
echo "config: $(git config --get hooks.foobar)"
exit 1
EOF
chmod +x .git/hooks/prepare-commit-msg

git rebase main
echo resolved >file
git add file
FOO=bar git -c hooks.foobar=hello rebase --continue
-- >8 --

The final command produces:

  in prepare-commit-msg hook
  FOO: bar
  config: hello
  error: could not commit staged changes.

which is what I'd expect. Do you get the same thing? If not, then I
wonder what could be different between our environments. If so, then I
wonder what is different from your earlier testing. :)

-Peff

```
