#!/bin/sh
# SPDX-License-Identifier: Apache-2.0
#
# Adds the Signed-off-by trailer CONTRIBUTING.md asks for to every commit, unless the message
# already carries one for you (git commit -s, a squash, a cherry-pick with -s). Enable it once per
# clone with:
#
#   git config core.hooksPath scripts/git-hooks
#
# There is no git setting that does this for `git commit` (format.signoff only affects format-patch).
msg=$1
name=$(git config user.name)
email=$(git config user.email)
[ -n "$name" ] && [ -n "$email" ] || exit 0
git interpret-trailers --in-place --if-exists addIfDifferent --trailer "Signed-off-by: $name <$email>" "$msg"
