threads / discuss / 46302

Request for git merge --signoff

Subject: Request for git merge --signoff

## tl;dr

6 messages between Jul 1, 2017 and Jul 25, 2017.

replies: 5people: 4as markdown or json

Dan Kohn· Jul 1, 2017, 15:24 UTC · lore

https://github.com/coreinfrastructure/best-practices-badge is a user of the https://github.com/probot/dco bot which checks that commits have a signoff. The issue is that there is no `--signoff` option in git for merge commits, which is a standard part of our workflow with feature branches. Here is a workflow where we currently get stuck:

```sh (master)$ git checkout -b feature-branch # make some changes (feature-branch)$ git commit -sam 'Adding features' # Changes have occurred on master so need to add them for easier merge (feature-branch)$ git fetch (feature-branch)$ git merge origin/master # Save default commit message (feature-branch)$ git push # This now fails the DCObot check because the merge commit is not signed. ```

This alternative workflow works, but is obviously tedious:

```sh # First 3 steps are the same (feature-branch)$ git merge origin/master # Save default commit message (feature-branch)$ git commit --amend -s # Commit message now has signoff line (feature-branch)$ git push # This now passes the DCObot check. ```

Or, I could manually add the Signoff line to the proposed git merge commit message, which would allow me to skip the `--amend` step.

Could you please add a `--signoff` option to `git merge`?

Probot issue reference: https://github.com/probot/dco/issues/13 -- Dan Kohn <mailto:dan@linuxfoundation.org> Executive Director, Cloud Native Computing Foundation <https://cncf.io/> tel:+1-415-233-1000

Junio C Hamano· Jul 1, 2017, 17:45 UTC · re: Dan Kohn · lore

Re: Request for git merge --signoff

Dan Kohn <dan@linuxfoundation.org> writes:
Show 16 quoted lines
> This alternative workflow works, but is obviously tedious:
>
> ```sh
> # First 3 steps are the same
> (feature-branch)$ git merge origin/master
> # Save default commit message
> (feature-branch)$ git commit --amend -s
> # Commit message now has signoff line
> (feature-branch)$ git push
> # This now passes the DCObot check.
> ```
>
> Or, I could manually add the Signoff line to the proposed git merge
> commit message, which would allow me to skip the `--amend` step.
>
> Could you please add a `--signoff` option to `git merge`?

The reason why we changed the default for "git merge" to start an editor at around v1.7.10 was because we wanted to encourage people to write log message that more meaningfully documents the change, and adding sign-off is probably in line with that.

I've done that "commit --amend" on a merge to tweak its message myself number of times, but I have to admit that I never did so for sign-off, but why not? ;-)

Dan Kohn· Jul 1, 2017, 18:15 UTC · re: Junio C Hamano · lore

Re: Request for git merge --signoff

On Sat, Jul 1, 2017 at 1:45 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Dan Kohn <dan@linuxfoundation.org> writes:
>> Could you please add a `--signoff` option to `git merge`?
> The reason why we changed the default for "git merge" to start an
> editor at around v1.7.10 was because we wanted to encourage people
> to write log message that more meaningfully documents the change,
> and adding sign-off is probably in line with that.
> I've done that "commit --amend" on a merge to tweak its message
> myself number of times, but I have to admit that I never did so for
> sign-off, but why not? ;-)

I'm not opposed to starting the editor, although in the case of our workflow there's not much more to say beyond "Merged in master". I would just like the Sign-Off line to appear by default in the commit message if I do `git merge origin/master --signoff`. I know it seems trivial, but many GitHub users aren't familiar with the exact header syntax to use, as they're used to just doing `git commit -sam 'New Feature'`.

Separately, I just came back from Beijing where Linus spoke at LC3 <https://www.lfasiallc.com/linuxcon-containercon-cloudopen-china>. He was asked about git and explained that he had largely bowed out of any development after the first few months and credited your stewardship. Even if you turn down my request for a new flag here, thanks for the amazing project! -- Dan Kohn <mailto:dan@linuxfoundation.org> Executive Director, Cloud Native Computing Foundation <https://cncf.io/> tel:+1-415-233-1000

Junio C Hamano· Jul 1, 2017, 20:25 UTC · re: Dan Kohn · lore

Re: Request for git merge --signoff

Dan Kohn <dan@linuxfoundation.org> writes:
Show 17 quoted lines
> On Sat, Jul 1, 2017 at 1:45 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Dan Kohn <dan@linuxfoundation.org> writes:
>
>>> Could you please add a `--signoff` option to `git merge`?
>
>> The reason why we changed the default for "git merge" to start an
>> editor at around v1.7.10 was because we wanted to encourage people
>> to write log message that more meaningfully documents the change,
>> and adding sign-off is probably in line with that.
>
>> I've done that "commit --amend" on a merge to tweak its message
>> myself number of times, but I have to admit that I never did so for
>> sign-off, but why not? ;-)
>
> I'm not opposed to starting the editor, although ...
> ...
> Even if you turn down my request for a new flag here,...

Was I a bit too oblique? I said that do think "merge --signoff" is in line with the latest philosophy, i.e. not rejecting the idea of add such an option. IOW, patches welcome (either from you or other people).

Ævar Arnfjörð Bjarmason· Jul 1, 2017, 22:15 UTC · re: Dan Kohn · lore

Re: Request for git merge --signoff

On Sat, Jul 01 2017, Dan Kohn jotted:
> https://github.com/coreinfrastructure/best-practices-badge is a user
> of the https://github.com/probot/dco bot which checks that commits
> have a signoff. The issue is that there is no `--signoff` option in
> git for merge commits.

I think it's fine to add such a feature, but it seems like an obvious bug to me in such a bot[1] that it's enforcing the DCO on merge commits.

The entire point of the DCO is to certify that you have the rights to submit the patch etc., it's quite dubious to be applying that to merge commits which contain no original work (most of the time, although of course a merge commit can have significant conflict resolution).

So yeah, it would make sense to have a --signoff option, especially to use when the merge actually does contain original work, but your stated reason for wanting this just seems like an easily solved bug in the bot: Exclude those commits that have no patch contents.

1. https://github.com/probot/dco/
Christian Couder· Jul 25, 2017, 05:42 UTC · re: Dan Kohn · lore

Re: Request for git merge --signoff

On Sat, Jul 1, 2017 at 5:24 PM, Dan Kohn <dan@linuxfoundation.org> wrote:
Show 5 quoted lines
> https://github.com/coreinfrastructure/best-practices-badge is a user
> of the https://github.com/probot/dco bot which checks that commits
> have a signoff. The issue is that there is no `--signoff` option in
> git for merge commits, which is a standard part of our workflow with
> feature branches. Here is a workflow where we currently get stuck:
[...]
> Or, I could manually add the Signoff line to the proposed git merge
> commit message, which would allow me to skip the `--amend` step.

Perhaps you could use a prepare-commit-msg hook (or maybe a commit-msg hook) to automatically add your Signoff line to any commit message if it isn't there already.

In the prepare-commit-msg hook sample there is already commented out code to do that:

https://github.com/git/git/blob/master/templates/hooks--prepare-commit-msg.sample#L35-L36

Alternatively you might want to use `git interpret-trailers` to do that or more fancy trailer related things.

> Could you please add a `--signoff` option to `git merge`?

I am not opposed to add a `--signoff` option to `git merge`, but I think the main plan to improve git in this area has been to first make it possible for git commands that can create commits to accept options like "--trailer 'Signed-off-by: Alice <alice@example.com>'" and to pass them to `git interpret-trailers` (or its underlying code).

← back to recent threads