aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcontrib/prepare-commit-msg13
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/prepare-commit-msg b/contrib/prepare-commit-msg
index cc9ba2e..969847d 100755
--- a/contrib/prepare-commit-msg
+++ b/contrib/prepare-commit-msg
@@ -49,6 +49,19 @@ elif [ $COMMIT_SOURCE = commit ]; then
# otherwise, assume a new commit with -C.
if [ $SHA1 = HEAD ]; then
cmd="diff --cached HEAD^"
+ if [ "$(git config gcc-config.mklog-hook-type)" = "smart-amend" ]; then
+ # Check if the existing message still describes the staged changes.
+ f=$(mktemp /tmp/git-commit.XXXXXX) || exit 1
+ git log -1 --pretty=email HEAD > $f
+ printf '\n---\n\n' >> $f
+ git $cmd >> $f
+ if contrib/gcc-changelog/git_email.py "$f" >/dev/null 2>&1; then
+ # Existing commit message is still OK for amended commit.
+ rm $f
+ exit 0
+ fi
+ rm $f
+ fi
else
cmd="diff --cached"
fi