Skip to content
Snippets Groups Projects
Commit 9a203bcd authored by Kaartic Sivaraam's avatar Kaartic Sivaraam Committed by Junio C Hamano
Browse files

hook: add sign-off using "interpret-trailers"


The sample hook to prepare the commit message before a commit allows
users to opt-in to add the sign-off to the commit message.  The
sign-off is added at a place that isn't consistent with the "-s"
option of "git commit".  Further, it could go out of view in certain
cases.

Add the sign-off in a way similar to "-s" option of "git commit"
using git's interpret-trailers command.

"interpret-trailers" alone works well in all cases except when the
user invokes "git commit" without any arguments.  In that case
manually add a new line after the first line to ensure it's
consistent with the output of "-s" option.

Signed-off-by: default avatarKaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent b56e96c4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -32,4 +32,8 @@ SHA1=$3
# esac
 
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$COMMIT_MSG_FILE" || echo "$SOB" >> "$COMMIT_MSG_FILE"
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
# if test -z "$COMMIT_SOURCE"
# then
# @PERL_PATH@ -i.bak -pe 'print "\n" if $first_line++ == 0' "$COMMIT_MSG_FILE"
# fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment