Kaartic Sivaraam <kaarticsivaraam91196@xxxxxxxxx> writes: > The sample hook to prepare the commit message before > a commit allows users to opt-in to add the signature > to the commit message. The signature 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 signature to the top of the commit message as it's > more appropriate and consistent with the "-s" option of git > commit. > > Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@xxxxxxxxx> > --- > The change might seem to be bit of an hack, but it seems > worth it (at least to me). I hope I haven't used any > commands that aren't portable. It does look like a hack. I was wondering if "interpret-trailers" is mature enough and can be used for this by now. Also the big comment before these examples say that this one you are updating is "rarely a good idea", though. By the way, the one that is still actually enabled is no longer needed. The commit template generated internally was corrected some time ago not to add the "Conflicts:" section without commenting it out. Have you tried "merge", "cherry-pick" and "commit --amend" with this patch on (meaning, with the "add sob at the top" logic in your actual hook that is enabled in your repository)? > templates/hooks--prepare-commit-msg.sample | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample > index 86b8f227e..3c8f5a53d 100755 > --- a/templates/hooks--prepare-commit-msg.sample > +++ b/templates/hooks--prepare-commit-msg.sample > @@ -33,4 +33,7 @@ case "$2,$3" in > esac > > # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') > -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" > +# SOB_TO_ADD=' > +# > +# '$SOB > +# grep -qs "^$SOB" "$1" || (echo "$SOB_TO_ADD" | cat - "$1" >temp-template && mv temp-template "$1")