]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - contrib/prepare-commit-msg
Update copyright years.
[thirdparty/gcc.git] / contrib / prepare-commit-msg
index cc9ba2e6ba1dadde6496934441297c06d5ec7906..48c9dad3c6f487cf8778e737e51d7cdf633d9d68 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# Copyright (C) 2020 Free Software Foundation, Inc.
+# Copyright (C) 2020-2023 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 #
@@ -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