{"thread":{"id":"64089","subject":"Config options -c in rebase --continue not passed to prepare-commit-msg hook","startedAt":"2025-09-04T12:46:28Z","lastAt":"2025-09-05T21:23:29Z","messageCount":2,"participants":["Devste Devste","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"525495","messageId":"CANM0SV0+t7x_VTtZNCO8rKo1vvxhJjwEdmjLDN70njxCo7DofQ@mail.gmail.com","threadId":"64089","inReplyTo":null,"subject":"Config options -c in rebase --continue not passed to prepare-commit-msg hook","fromName":"Devste Devste","fromEmail":"devstemail@gmail.com","sentAt":"2025-09-04T12:46:13Z","receivedAt":"2025-09-04T12:46:28Z","isPatch":false,"sender":{"key":"devstemail@gmail.com","avatar":null},"body":"For some reason neither environment variables nor -c is passed to the\nprepare-commit-msg hook when rebasing.\nOther parameters (e.g. -C /path/to/repo) are passed correctly/it's\nrunning the command in the correct repo\n\nReproduction:\n1) Create a prepare-commit-msg hook with content\necho \"prepare-commit-msg hook\"\necho \"$FOO\"\ngit config --get hooks.foobar\nexit 1\n\n2) rebase a branch with conflicts. After resolving a conflict run:\nFOO=bar git -c hooks.foobar=hello rebase --continue\n\nThe hook is executed but neither $FOO nor the config are set (both\necho an empty line)\nOutput:\nprepare-commit-msg hook\n\n\n\nExpected output:\nprepare-commit-msg hook\nbar\nhello\n\nGit 2.51.0\n"},{"id":"525676","messageId":"20250905212321.GA612697@coredump.intra.peff.net","threadId":"64089","inReplyTo":"CANM0SV0+t7x_VTtZNCO8rKo1vvxhJjwEdmjLDN70njxCo7DofQ@mail.gmail.com","subject":"Re: Config options -c in rebase --continue not passed to prepare-commit-msg hook","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2025-09-05T21:23:21Z","receivedAt":"2025-09-05T21:23:29Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 04, 2025 at 02:46:13PM +0200, Devste Devste wrote:\n\n> For some reason neither environment variables nor -c is passed to the\n> prepare-commit-msg hook when rebasing.\n> Other parameters (e.g. -C /path/to/repo) are passed correctly/it's\n> running the command in the correct repo\n\nIf the environment is being cleared, then that would explain \"-c\" as\nwell, since it passes through the environment. However, I can't\nreproduce the problem here.\n\nThis is my full recipe:\n\n-- >8 --\ngit init\ngit checkout main\necho base >file && git add file && git commit -m base\necho main >>file && git commit -am main\ngit checkout -b side HEAD^\necho side >>file && git commit -am side\n\n\ncat >.git/hooks/prepare-commit-msg <<\\EOF\n#!/bin/sh\necho \"in prepare-commit-msg hook\"\necho \"FOO: $FOO\"\necho \"config: $(git config --get hooks.foobar)\"\nexit 1\nEOF\nchmod +x .git/hooks/prepare-commit-msg\n\ngit rebase main\necho resolved >file\ngit add file\nFOO=bar git -c hooks.foobar=hello rebase --continue\n-- >8 --\n\nThe final command produces:\n\n  in prepare-commit-msg hook\n  FOO: bar\n  config: hello\n  error: could not commit staged changes.\n\nwhich is what I'd expect. Do you get the same thing? If not, then I\nwonder what could be different between our environments. If so, then I\nwonder what is different from your earlier testing. :)\n\n-Peff\n"}]}