Re: [PATCH] commit: add --committer option
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- Nov 12, 2025, 16:46 UTC
- Message-ID
- <CAOLTT8SZXooypwP27BFXaQdETTPFqOVxGtNtO6j=p7WgaBeLgQ@mail.gmail.com>
- In-Reply-To
- <20251111213339.GA4053071@coredump.intra.peff.net>
Jeff King <peff@peff.net> 于2025年11月12日周三 05:33写道:
Show 47 quoted lines
> > On Tue, Nov 11, 2025 at 12:16:40PM -0800, Junio C Hamano wrote: > > > Jeff King <peff@peff.net> writes: > > > > >> Sometimes it's because I forgot to configure the repository-level git user > > >> config and started development first. Only when I tried to correct the > > >> committer did I feel the pain. > > > > > > OK, this workflow does make sense to me. Fixing up an earlier mistake is > > > inherently a one-off thing, and a command-line option is more ergonomic > > > than using the environment variables. > > > > Not very much, at least to me. Fixing up an earlier mistake may be > > one-shot thing but it is to correct multiple commits in one go, > > which would be error prone if you do so with "git commit --option". > > Either "fast-export | fast-import" pipe, or "git rebase" (which this > > patch does not give --committer option, but it already knows how to > > honor existing environment variables) would be used for that, no? > > I usually lean on "commit --amend" for this, coupled with rebase if > there are multiple commits. So I've used: > > git rebase -x "git commit --no-edit --amend --author=..." > > or similar when fixing up incorrect application of somebody else's > patches (e.g., if I ended up using "git apply" and tweaking the commit > message myself, rather than using "git am"). > > > > Two small thoughts: > > > > > > - I suspect what you'd usually want there is for the committer and the > > > author to match. We have --committer-date-is-author-date for rebase, > > > and conceptually I think something like --committer-is-author would > > > do what you want here. But obviously it's less flexible, and I don't > > > know if it's that much easier to use. > > > > I am not sure how the user experience of this would look like. > > I just mean being able to do: > > git commit --amend --author='Foo Bar <foo@example.com>' --committer-is-author > > instead of: > > git commit --amend --author='Foo Bar <foo@example.com>' --committer='Foo Bar <foo@example.com>' >
If I wanted an elegant parameter myself, it would definitely be `git commit --amend --user='Foo Bar <foo@example.com>'`, instead of `-A -B-is-A`
> -Peff