How to add signed-off-by lines by amending Git commit messages (using git-interpret-trailers)

‘Signed-off-by:’ tag indicates that the signer was involved in the development of the patch, or that he/she was in the patch’s delivery path. Its simple line at the end of the explanation for the patch, which certifies that you wrote it or otherwise have the right to pass it on as a open-source patch.

‘Acked-by:, Cc:’ is used by the maintainer of the affected code when that maintainer neither contributed to nor forwarded the patch. If a person has had the opportunity to comment on a patch, but has not provided such comments, you may optionally add a “Cc:” tag to the patch.

If this patch fixes a problem reported by somebody else, consider adding a ‘Reported-by:’ tag to credit the reporter for their contribution. A ‘Tested-by:’ tag indicates that the patch has been successfully tested (in some environment) by the person named. ‘Reviewed-by:’, instead, indicates that the patch has been reviewed and found acceptable.

# amend commit with signed-off-by
$ git commit --amend --signoff
$ git log
...
Signed-off-by: Alice <alice@example.com>
# configure a 'sign' trailer with a 'Signed-off-by' key, and then add two of these trailers to a message
$ git config trailer.sign.key "Signed-off-by"
$ cat msg.txt
subject
message
$ cat msg.txt | git interpret-trailers --trailer 'sign: Alice <alice@example.com>' --trailer 'sign: Bob <bob@example.com>'
subject
message
Signed-off-by: Alice <alice@example.com>
Signed-off-by: Bob <bob@example.com>

# extract the last commit as a patch, and add a Cc and a Reviewed-by trailer to it
$ git format-patch -1
0001-foo.patch
$ git interpret-trailers --trailer 'Cc: Alice <alice@example.com>' --trailer 'Reviewed-by: Bob <bob@example.com>' 0001-foo.patch >0001-bar.patch

# configure a sign trailer with a command to automatically add a 'Signed-off-by: ' with the author information only if there is no 'Signed-off-by: ' already
$ git config trailer.sign.key "Signed-off-by: "
$ git config trailer.sign.ifmissing add
$ git config trailer.sign.ifexists doNothing
$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"'
$ git interpret-trailers < EOF
Signed-off-by: Bob <bob@example.com>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s