Subject: Re: Skipping adding Signed-off-by even if it's not the last on git commit

From: Junio C Hamano <[email-masked]>
Date: Fri, 09 Dec 2022 10:23:52 +0900

Jeff King <[email-masked]> writes:

> This made me curious about the opposite: is there config you can set to
> get this behavior for --signoff? I think the answer is "no". You can do:
>
>   git -c trailer.ifExists=addIfDifferent \
>       commit --amend --trailer="Signed-off-by: Jeff King <[email-masked]>"
>
> to get the desired behavior, but using "--signoff" does not respect
> trailer settings.

A customization to allow addIfDifferent may be an interesting idea.

> I feel like config is probably a better match for the use cases here,
> because the decision about de-duping is not something you'd usually set
> for one particular operation, but is more likely to be a project policy
> about what the trailer means (and that includes Signed-off-by). So you'd
> want to set it per-repo, not per-operation.

Sure.

> ... The one exception is that the
> generic trailer.ifExists, etc, would start affecting --signoff, which
> _might_ be a surprise. If we wanted to retain the behavior there, we
> could say "--signoff is special, and doesn't respect generic trailer
> config".

Yeah, that may be safe, however it is very unsatisfying.

> Alternatively, it would be nice if there was an easy way to put your
> ident into a trailer (what I wrote above doesn't really work unless you
> have those variables in your environment, and of course it's a lot of
> typing). I think you can hack it up like:
>
>   git config trailer.sign.key Signed-off-by
>   git config trailer.sign.cmd \
>     'git var GIT_COMMITTER_IDENT | sed "s/>.*/>/";:'
>   git commit --trailer=sign
>
> which is only a little more typing than --signoff, but it's not very
> ergonomic.

It does not look _too_ bad, though.