On 09/06/20 20:42 +0100, Jonathan Wakely wrote:
Also add comment explaining what the script does.
contrib/ChangeLog:
* gcc-changelog/git_email.py: Set exit status on error.
Committed as obvious.
With that change to git_email.py I can use the following change to the
contrib/prepare-commit-msg hook to avoid adding redundant mklog.py
output when amending a commit:
--- ../contrib/prepare-commit-msg 2020-06-09 19:18:01.048028044 +0100
+++ ../.git/hooks/prepare-commit-msg 2020-06-09 20:36:09.587850393 +0100
@@ -49,6 +49,17 @@
# otherwise, assume a new commit with -C.
if [ $SHA1 = HEAD ]; then
cmd="diff --cached HEAD^"
+ check=contrib/gcc-changelog/git_email.py
+ 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
else
cmd="diff --cached"
fi
This way the mklog.py command only appends a skeleton changelog if the
existing log message fails verification for the amended commit.
Is this worth adding to contrib/prepare-commit-msg?
commit 62963c60fc19d07615afe9d4f1b897b2f60801b2
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Tue Jun 9 20:39:39 2020 +0100
gcc-changelog: Use non-zero exit status on error
Also add comment explaining what the script does.
contrib/ChangeLog:
* gcc-changelog/git_email.py: Set exit status on error.
diff --git a/contrib/gcc-changelog/git_email.py
b/contrib/gcc-changelog/git_email.py
index 367cf76d8ee..bf74bd8b156 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -70,6 +70,9 @@ class GitEmail(GitCommit):
strict=strict)
+# With zero arguments, process every patch file in the ./patches directory.
+# With one argument, process the named patch file.
+# Patch files must be in 'git format-patch' format.
if __name__ == '__main__':
if len(sys.argv) == 1:
allfiles = []
@@ -100,3 +103,4 @@ if __name__ == '__main__':
if not email.lines:
print('Error: patch contains no parsed lines', file=sys.stderr)
email.print_errors()
+ sys.exit(1)