ChangeLog files - server and client scripts

Message ID b783cfa6-9903-6899-ecd0-9eeeee2be229@suse.cz
State New
Headers show
Series
  • ChangeLog files - server and client scripts
Related show

Commit Message

Martin Liška May 13, 2020, 11:05 a.m.
Hi.

I'm sending the gcc-changelog relates scripts which should be added to contrib
folder. The patch contains:
- git_check_commit.py - checking script that verifies git message format
- git_update_version.py - a replacement of maintainer-scripts/update_version_git which
bumps DATESTAMP and generates ChangeLog entries (for now into ChangeLog.test files)
- git_commit.py, git_email.py and git_repository.py - helper classes

I also added a new git.config alias: 'gcc-verify' which can be used in the following
way:

$ git gcc-verify HEAD~2..HEAD -p -n
Checking 0e4009e9d523270e26856d2441c1be3d8119a477
OK
@@CL contrib
2020-05-13  Martin Liska  <mliska@suse.cz>

	* gcc-changelog/git_check_commit.py: New file.
	* gcc-changelog/git_commit.py: New file.
	* gcc-changelog/git_email.py: New file.
	* gcc-changelog/git_repository.py: New file.
	* gcc-changelog/git_update_version.py: New file.
	* gcc-git-customization.sh: Add gcc-verify alias.
@@CL
Checking 18edc195442291525e04f0fa4d5ef972155117da
OK
@@CL gcc
2020-05-13  Jakub Jelinek  <jakub@redhat.com>

	PR debug/95080
	* cfgrtl.c (purge_dead_edges): Skip over debug and note insns even
	if the last insn is a note.
@@CL gcc/testsuite
2020-05-13  Jakub Jelinek  <jakub@redhat.com>

	PR debug/95080
	* g++.dg/opt/pr95080.C: New test.
@@CL

Note the -n option which disables _strict mode_ (modification of both ChangeLog
and another files).

The second part is git hook that will reject all commits for release and master branches.
that violate ChangeLog format. Right now, strict mode is disabled in the hooks.

What's still missing to be done is format of Revert and Backport commits.
I suggest to use native 'git revert XYZ' and 'git cherry-pick -x XYZ'.
Doing that the commit messages will provide link to original commit and the script
can later append corresponding 'Backported ..' or 'Reverted' line.

Thoughts?
Martin

Comments

Martin Liška May 13, 2020, 12:35 p.m. | #1
The scripts were just installed to master except the git alias.
I'm sending that in a separate patch. Now the alias can be used
from any subfolder in a gcc git repository.

Martin
From eb47191e8d8cbbda285c4df7eb2d1e98091edab9 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>

Date: Wed, 13 May 2020 14:32:50 +0200
Subject: [PATCH] Add gcc-verify alias.

contrib/ChangeLog:

2020-05-13  Martin Liska  <mliska@suse.cz>

	* gcc-git-customization.sh: Add gcc-verify alias
	that uses contrib/gcc-changelog/git_check_commit.py.
---
 contrib/gcc-git-customization.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh
index a932bf8c06a..ce293d1fe42 100755
--- a/contrib/gcc-git-customization.sh
+++ b/contrib/gcc-git-customization.sh
@@ -25,6 +25,8 @@ git config alias.svn-rev '!f() { rev=$1; shift; git log --all --grep="^From-SVN:
 git config alias.gcc-descr \!"f() { if test \${1:-no} = --full; then c=\${2:-master}; r=\$(git describe --all --abbrev=40 --match 'basepoints/gcc-[0-9]*' \$c | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-,r,p'); expr match \${r:-no} '^r[0-9]\\+\$' >/dev/null && r=\${r}-0-g\$(git rev-parse \${2:-master}); else c=\${1:-master}; r=\$(git describe --all --match 'basepoints/gcc-[0-9]*' \$c | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-\\([0-9]\\+\\)-\\([0-9]\\+\\)-g[0-9a-f]*\$,r\\2-\\3,p;s,^\\(tags/\\)\\?basepoints/gcc-\\([0-9]\\+\\)\$,r\\2-0,p'); fi; if test -n \$r; then o=\$(git config --get gcc-config.upstream); rr=\$(echo \$r | sed -n 's,^r\\([0-9]\\+\\)-[0-9]\\+\\(-g[0-9a-f]\\+\\)\\?\$,\\1,p'); if git rev-parse --verify --quiet \${o:-origin}/releases/gcc-\$rr >/dev/null; then m=releases/gcc-\$rr; else m=master; fi; git merge-base --is-ancestor \$c \${o:-origin}/\$m && \echo \${r}; fi; }; f"
 git config alias.gcc-undescr \!"f() { o=\$(git config --get gcc-config.upstream); r=\$(echo \$1 | sed -n 's,^r\\([0-9]\\+\\)-[0-9]\\+\$,\\1,p'); n=\$(echo \$1 | sed -n 's,^r[0-9]\\+-\\([0-9]\\+\\)\$,\\1,p'); test -z \$r && echo Invalid id \$1 && exit 1; h=\$(git rev-parse --verify --quiet \${o:-origin}/releases/gcc-\$r); test -z \$h && h=\$(git rev-parse --verify --quiet \${o:-origin}/master); p=\$(git describe --all --match 'basepoints/gcc-'\$r \$h | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-[0-9]\\+-\\([0-9]\\+\\)-g[0-9a-f]*\$,\\2,p;s,^\\(tags/\\)\\?basepoints/gcc-[0-9]\\+\$,0,p'); git rev-parse --verify \$h~\$(expr \$p - \$n); }; f"
 
+git config alias.gcc-verify '!f() { "`git rev-parse --show-toplevel`/contrib/gcc-changelog/git_check_commit.py" $@; } ; f'
+
 # Make diff on MD files use "(define" as a function marker.
 # Use this in conjunction with a .gitattributes file containing
 # *.md    diff=md
-- 
2.26.2
Richard Earnshaw May 13, 2020, 1:24 p.m. | #2
On 13/05/2020 12:05, Martin Liška wrote:
> Hi.

> 

> I'm sending the gcc-changelog relates scripts which should be added to

> contrib

> folder. The patch contains:

> - git_check_commit.py - checking script that verifies git message format

> - git_update_version.py - a replacement of

> maintainer-scripts/update_version_git which

> bumps DATESTAMP and generates ChangeLog entries (for now into

> ChangeLog.test files)

> - git_commit.py, git_email.py and git_repository.py - helper classes

> 

> I also added a new git.config alias: 'gcc-verify' which can be used in

> the following

> way:

> 

> $ git gcc-verify HEAD~2..HEAD -p -n

> Checking 0e4009e9d523270e26856d2441c1be3d8119a477

> OK

> @@CL contrib

> 2020-05-13  Martin Liska  <mliska@suse.cz>

> 

>     * gcc-changelog/git_check_commit.py: New file.

>     * gcc-changelog/git_commit.py: New file.

>     * gcc-changelog/git_email.py: New file.

>     * gcc-changelog/git_repository.py: New file.

>     * gcc-changelog/git_update_version.py: New file.

>     * gcc-git-customization.sh: Add gcc-verify alias.

> @@CL

> Checking 18edc195442291525e04f0fa4d5ef972155117da

> OK

> @@CL gcc

> 2020-05-13  Jakub Jelinek  <jakub@redhat.com>

> 

>     PR debug/95080

>     * cfgrtl.c (purge_dead_edges): Skip over debug and note insns even

>     if the last insn is a note.

> @@CL gcc/testsuite

> 2020-05-13  Jakub Jelinek  <jakub@redhat.com>

> 

>     PR debug/95080

>     * g++.dg/opt/pr95080.C: New test.

> @@CL

> 

> Note the -n option which disables _strict mode_ (modification of both

> ChangeLog

> and another files).

> 

> The second part is git hook that will reject all commits for release and

> master branches.

> that violate ChangeLog format. Right now, strict mode is disabled in the

> hooks.

> 

> What's still missing to be done is format of Revert and Backport commits.

> I suggest to use native 'git revert XYZ' and 'git cherry-pick -x XYZ'.

> Doing that the commit messages will provide link to original commit and

> the script

> can later append corresponding 'Backported ..' or 'Reverted' line.

> 

> Thoughts?

> Martin


I've just realized this doesn't give us an easy way to mark changes for
the root-level ChangeLog file, unless, perhaps "@@ CL ." works?

R.
Martin Liška May 13, 2020, 1:33 p.m. | #3
On 5/13/20 3:24 PM, Richard Earnshaw wrote:
> I've just realized this doesn't give us an easy way to mark changes for

> the root-level ChangeLog file, unless, perhaps "@@ CL ." works?


This works fine:
'ChangeLog:'

as seen for instance here:

commit 9ad3c1d81c129fc76594b9df5b798c380cbf03ee
Author: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Date:   Wed Apr 22 09:20:08 2020 +0200

     MAINTAINERS: add myself for write after approval
     
     ChangeLog:
     
     2020-04-22  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
     
             * MAINTAINERS (Write After Approval): add myself

Martin
Joseph Myers May 13, 2020, 5:53 p.m. | #4
On Wed, 13 May 2020, Martin Liška wrote:

> I'm sending the gcc-changelog relates scripts which should be added to contrib

> folder. The patch contains:

> - git_check_commit.py - checking script that verifies git message format


We need a documentation patch to contribute.html or gitwrite.html that 
describes the exact commit message format being used.

> - git_update_version.py - a replacement of

> maintainer-scripts/update_version_git which

> bumps DATESTAMP and generates ChangeLog entries (for now into ChangeLog.test

> files)


Where does this check things out?  (The existing ~gccadmin/gcc-checkout 
isn't suitable for that, it needs to stay on master to have the correct 
version of maintainer-scripts rather than being switched to other 
branches, though I suppose a second long-lived checkout that gets updated 
automatically could be used.  If you check things out somewhere else 
temporarily, it's important to be sure the checkout gets deleted 
afterwards rather than having multiple checkouts accumulating.  That's 
especially the case if you use a checkout in /tmp as a single GCC 
repository clone / checkout uses a significant proportion of the free 
space on the root filesystem; /sourceware/snapshot-tmp/gcc has more free 
space for large temporary directories.)

> The second part is git hook that will reject all commits for release and

> master branches.

> that violate ChangeLog format. Right now, strict mode is disabled in the

> hooks.


Note that the present state of having GCC-specific patches to the git 
hooks is supposed to be a temporary one; we want to move to all relevant 
GCC-specific configuration being in refs/meta/config rather than custom 
code, so GCC and sourceware can share a single instance of the hooks which 
in turn can use the same code as in the upstream AdaCore repository, so 
that future updates of the hooks from upstream are easier.  See the issues 
I filed at https://github.com/AdaCore/git-hooks/issues for the existing 
custom GCC changes and the pull request 
https://github.com/AdaCore/git-hooks/pull/12 to bring in implementations 
of many of those features (not sure if it covers everything or not).  So 
it's important to consider how these checks could be implemented without 
needing GCC-specific code directly in these hooks (for example, using the 
new hooks.update-hook mechanism added by one of the commits in that pull 
request, or getting extra features added to the upstream hooks in a 
generic form if necessary).

-- 
Joseph S. Myers
joseph@codesourcery.com
Martin Liška May 14, 2020, 12:48 p.m. | #5
On 5/13/20 7:53 PM, Joseph Myers wrote:
> On Wed, 13 May 2020, Martin Liška wrote:

> 

>> I'm sending the gcc-changelog relates scripts which should be added to contrib

>> folder. The patch contains:

>> - git_check_commit.py - checking script that verifies git message format

> 

> We need a documentation patch to contribute.html or gitwrite.html that

> describes the exact commit message format being used.


Sure, I'm sending patch for that.

> 

>> - git_update_version.py - a replacement of

>> maintainer-scripts/update_version_git which

>> bumps DATESTAMP and generates ChangeLog entries (for now into ChangeLog.test

>> files)

> 

> Where does this check things out?  (The existing ~gccadmin/gcc-checkout

> isn't suitable for that, it needs to stay on master to have the correct

> version of maintainer-scripts rather than being switched to other

> branches, though I suppose a second long-lived checkout that gets updated

> automatically could be used.  If you check things out somewhere else

> temporarily, it's important to be sure the checkout gets deleted

> afterwards rather than having multiple checkouts accumulating.  That's

> especially the case if you use a checkout in /tmp as a single GCC

> repository clone / checkout uses a significant proportion of the free

> space on the root filesystem; /sourceware/snapshot-tmp/gcc has more free

> space for large temporary directories.)


Well, we can make a proper git clone of the original repository that will
be used for the daily bumps. I bet we'll have a place for one more clone?

> 

>> The second part is git hook that will reject all commits for release and

>> master branches.

>> that violate ChangeLog format. Right now, strict mode is disabled in the

>> hooks.

> 

> Note that the present state of having GCC-specific patches to the git

> hooks is supposed to be a temporary one; we want to move to all relevant

> GCC-specific configuration being in refs/meta/config rather than custom

> code, so GCC and sourceware can share a single instance of the hooks which

> in turn can use the same code as in the upstream AdaCore repository, so

> that future updates of the hooks from upstream are easier.  See the issues

> I filed at https://github.com/AdaCore/git-hooks/issues for the existing

> custom GCC changes and the pull request

> https://github.com/AdaCore/git-hooks/pull/12 to bring in implementations

> of many of those features (not sure if it covers everything or not).  So

> it's important to consider how these checks could be implemented without

> needing GCC-specific code directly in these hooks (for example, using the

> new hooks.update-hook mechanism added by one of the commits in that pull

> request, or getting extra features added to the upstream hooks in a

> generic form if necessary).

> 


I welcome the attempt to unify the hooks with AdaCore upstream. I believe this
should not block gcc-changelog attempt now. Later on, we can add it to
hooks.update-hook mechanism.

Thanks,
Martin
diff --git a/htdocs/codingconventions.html b/htdocs/codingconventions.html
index f4732ef6..ffa6db32 100644
--- a/htdocs/codingconventions.html
+++ b/htdocs/codingconventions.html
@@ -112,9 +112,14 @@ maintained and kept up to date.  In particular:</p>
 
 <h2 id="ChangeLogs">ChangeLogs</h2>
 
-<p>GCC requires ChangeLog entries for documentation changes; for the web
-pages (apart from <code>java/</code> and <code>libstdc++/</code>) the CVS
-commit logs are sufficient.</p>
+<p>
+ChangeLog entries are part of git commit messages and are automatically put
+into a corresponding ChangeLog file.  A ChangeLog template can be easily generated
+with <code>./contrib/mklog</code> script.  GCC offers a checking script that
+verifies a proper ChangeLog formatting (see <code>git gcc-verify</code> git alias).
+for a particular git commit.  The checking script covers most commonly used ChangeLog
+formats and the following paragraphs explain what it supports.
+</p>
 
 <p>See also what the <a
 href="http://www.gnu.org/prep/standards_toc.html">GNU Coding
@@ -124,19 +129,95 @@ in comments rather than the ChangeLog, though a single line overall
 description of the changes may be useful above the ChangeLog entry for
 a large batch of changes.</p>
 
-<p>For changes that are ported from another branch, we recommend to
-use a single entry whose body contains a verbatim copy of the original
-entries describing the changes on that branch, possibly preceded by a
-single-line overall description of the changes.</p>
+<h3>Components</h3>
+
+<ul>
+    <li><code class="other">git_description</code> - a leading text with git commit description</li>
+    <li><code class="other">author_timestamp</code> - line with timestamp and an author name and email (2 spaces before and after name) <br>
+        example: <code class="other">2020-04-23␣␣Martin Liska␣␣&lt;mliska@suse.cz&gt;</code></li>
+    <li><code class="other">additional_author</code> - line with additional commit author name and email (starting with a tabular and 4 spaces) <br>
+        example: <code class="other">\t␣␣␣␣Martin Liska␣␣&lt;mliska@suse.cz&gt;</code></li>
+    <li><code class="other">changelog_location</code> - a location to a ChangeLog file <br>
+        supported formats: <code class="other">a/b/c/ChangeLog</code>, <code class="other">a/b/c/ChangeLog:</code>, <code class="other">a/b/c/</code> (where ChangeLog file lives in the folder), <code class="other">\ta/b/c/</code> and <code class="other">a/b/c</code></li>
+    <li><code class="other">pr_entry</code> - bug report reference <br>
+        example: <code class="other">\tPR component/12345</code></li>
+    <li><code class="other">changelog_file</code> - a modified file mentined in a ChangeLog:
+        supported formats: <code class="other">\t* a/b/c/file.c:</code>, <code class="other">\t* a/b/c/file.c (function):</code>, <code class="other">\t* a/b/c/file1.c, a/b/c/file2.c:</code></li>
+    <li><code class="other">changelog_file_comment</code> - line that follows a <code class="other">changelog_file</code> with description of changes in the file;
+        must start with <code class="other">\t</code></li>
+    <li><code class="other">co_authored_by</code> - <a href="https://help.github.com/en/github/committing-changes-to-your-project/creating-a-commit-with-multiple-authors">GitHub format</a> for a Co-Authored-By</li>
+</ul>
+
+<h3>Format rules</h3>
+
+<ul>
+    <li><code class="other">git_description</code> - optional; ends right before one of the other compoments is found</li>
+    <li><code class="other">author_timestamp</code> - optional; when found before a <code class="other">changelog_file</code>, then it is added
+    to each changelog entry</li>
+    <li><code class="other">additional_author</code> - optional</li>
+    <li><code class="other">changelog_location</code> - optional; parser attempts to identify ChangeLog file based
+    on modified files; <code class="other">$changelog_location</code> belonging to a different ChangeLog must
+    be separated with an empty line</li>
+    <li><code class="other">pr_entry</code> - optional; can contain any number of PR entries</li>
+    <li><code class="other">changelog_file</code> - each <code>changelog_location</code> must contain at least one file</li>
+    <li><code class="other">changelog_file_comment</code> - optional</li>
+    <li><code class="other">co_authored_by</code> - optional, can contain more than one</li>
+</ul>
+
+<h3>Documented behaviour</h3>
+
+<ul>
+    <li>a missing <code class="other">changelog_location</code> file location can be deduced based on group of <code class="other">changelog_file</code>s</li>
+    <li>script automatically generates missing "New file." entries for files that are added in a commit</li>
+    <li>changed files that are not mentioned in a ChangeLog file generate an error</li>
+    <li>similarly for unchanged files that are mentioned in a ChangeLog file</li>
+    <li>a commit author and date stamp can be automatically deduced from a git commit - we recommend to use it</li>
+    <li><code class="other">co_authored_by</code> is added to each ChangeLog entry</li>
+    <li>a PR component is checked against list of valid components</li>
+    <li><code>ChangeLog</code> files, <code>DATESTAMP</code>, <code>BASE-VER</code> and <code>DEV-PHASE</code> can be modified only separately from other files</li>
+</ul>
 
-<p>There is no established convention on when ChangeLog entries are to
-be made for testsuite changes; see messages <a
-href="https://gcc.gnu.org/ml/gcc/2000-09/msg00287.html">1</a> and <a
-href="https://gcc.gnu.org/ml/gcc/2000-09/msg00290.html">2</a>.</p>
+<h3>Example patch</h3>
 
-<p>If your change fixes a PR, put <code>PR java/58</code> (where
-<code>java/58</code> is the actual number of the PR) at the top
-of the ChangeLog entry.</p>
+<pre><code>This patch adds a second movk pattern that models the instruction
+as a "normal" and/ior operation rather than an insertion.  It fixes
+the third insv_1.c failure in PR87763, which was a regression from
+GCC 8.
+
+2020-02-06  John Foo  &lt;john@example.com&gt;
+
+gcc/
+	PR target/87763
+	* config/aarch64/aarch64-protos.h (aarch64_movk_shift): Declare.
+	* config/aarch64/aarch64.c (aarch64_movk_shift): New function.
+	* config/aarch64/aarch64.md (aarch64_movk&lt;mode&gt;): New pattern.
+
+gcc/testsuite/
+	PR target/87763
+	* gcc.target/aarch64/movk_2.c: New test.
+
+Co-Authored-By: Jack Bar  &lt;jack@example.com&gt;
+</code></pre>
+
+<h3>Tokenized patch</h3>
+
+<pre>
+<code>$git_description
+
+$author_timestamp
+
+$changelog_location
+$pr_entry
+$changelog_file
+$changelog_file
+$changelog_file
+
+$changelog_location
+$pr_entry
+$changelog_file
+
+$co_authored_by</code>
+</pre>
 
 <h2 id="Portability">Portability</h2>
 
@@ -201,7 +282,6 @@ minimize the number of function prototypes, by defining them before
 their first use.  Function prototypes should only be used when
 necessary, to break mutually recursive cycles.</p>
 
-
 <h2 id="Makefiles">Makefiles</h2>
 
 <p><code>touch</code> should never be used in GCC Makefiles.  Instead
diff --git a/htdocs/contribute.html b/htdocs/contribute.html
index 3d03b9d1..80a4470e 100644
--- a/htdocs/contribute.html
+++ b/htdocs/contribute.html
@@ -177,22 +177,10 @@ testcases cannot be added.
 
 <dt>ChangeLog</dt>
 <dd>
-A ChangeLog entry as plaintext; see the various ChangeLog files for
-format and content, and the <a href="codingconventions.html">GCC
+A ChangeLog entry as plaintext; see the <a href="codingconventions.html#ChangeLogs">GCC
 coding conventions</a> and <a
 href="http://www.gnu.org/prep/standards_toc.html">GNU Coding
-Standards</a> for further information.  The ChangeLog entries should
-be plaintext rather than part of the patch since the top of the
-ChangeLog changes rapidly and a patch to the ChangeLog would probably
-no longer apply by the time your patch is reviewed.
-If your change fixes a PR, put text in the ChangeLog entry mentioning
-the PR.  Our infrastructure understands how to
-extract this information and automatically append the commit log to
-the PR.  In order to be recognized, the text must fit a particular
-form.  It must start with "PR", and then must include the category
-and PR number.  For instance, <code>PR java/2369</code> is
-valid.  Multiple PRs can be mentioned in a single message.
-</dd>
+Standards</a> for further information.</dd>
 
 <dt>Bootstrapping and testing</dt>
 <dd>
diff --git a/htdocs/gitwrite.html b/htdocs/gitwrite.html
index 97d60870..791213a5 100644
--- a/htdocs/gitwrite.html
+++ b/htdocs/gitwrite.html
@@ -25,7 +25,6 @@ maintainers and significant developers.</p>
   <li><a href="#checkin">Checking in a change</a></li>
   <li><a href="#example">Example check-in session</a></li>
   <li><a href="#branches">Creating and using branches</a></li>
-  <li><a href="#changelog">git-merge-changelog</a></li>
   <li><a href="#vendor">Personal and Vendor branches</a></li>
   <li><a href="#account">Tips&amp;Tricks around your account</a></li>
 </ol>
@@ -237,9 +236,10 @@ pull</code>" before attempting a checkin; this will save you a little
 time if someone else has modified the source tree since the last time
 you synced your sources.</li>
 
-<li>Apply the patch to your local tree and update the ChangeLog file.
-Use the current date/time for the ChangeLog entry, not the time that
-the patch was submitted.</li>
+<li>Apply the patch to your local tree.  ChangeLog entries will be
+automatically added to the corresponding ChangeLog files based
+on the git commit message.  See the documentation of
+<a href="codingconventions.html#ChangeLogs">ChangeLog format</a>.</li>
 
 <li>Make sure to rebuild any generated files that would be affected by
 the patch.  Make sure to check them in along with the files explicitly
@@ -347,30 +347,6 @@ accordingly.  It may be easier to cherry-pick some smaller changes onto master
 don't need to <code>merge --squash</code> squash, but still need to make sure
 the commits on the branch satisfy the above rules for commits.
 
-<hr />
-<h2 id="changelog">git-merge-changelog</h2>
-
-git's native handling of ChangeLog merges is pretty bad, but there's a separate
-git-merge-changelog tool that improves things dramatically.  Some operating
-system distributions have a git-merge-changelog package already, or to build it
-by hand you can do
-
-<blockquote><pre>
-git clone git://git.savannah.gnu.org/gnulib.git
-cd gnulib
-./gnulib-tool --create-testdir --dir=/tmp/testdir123 git-merge-changelog
-cd /tmp/testdir123
-./configure
-make
-make install
-</pre></blockquote>
-And then to enable it, do
-<blockquote><pre>
-git config --global merge.merge-changelog.name "GNU-style ChangeLog merge driver"
-git config --global merge.merge-changelog.driver "git-merge-changelog %O %A %B"
-echo "ChangeLog*   merge=merge-changelog" >> $GCCSRCDIR/.git/info/attributes
-</pre></blockquote>
-
 <hr />
 <h2 id="vendor">Personal and vendor branches</h2>
 
@@ -457,6 +433,7 @@ repository:</p>
   </li>
   <li><i>gcc-descr</i> - Undocumented</li>
   <li><i>gcc-undescr</i> - Undocumented</li>
+  <li><i>gcc-verify</i> - Undocumented</li>
 </ul>
 
 <p>The final customization that the script makes is to add a diff rule so
Joseph Myers May 14, 2020, 4:47 p.m. | #6
On Thu, 14 May 2020, Martin Liška wrote:

> On 5/13/20 7:53 PM, Joseph Myers wrote:

> > On Wed, 13 May 2020, Martin Liška wrote:

> > 

> > > I'm sending the gcc-changelog relates scripts which should be added to

> > > contrib

> > > folder. The patch contains:

> > > - git_check_commit.py - checking script that verifies git message format

> > 

> > We need a documentation patch to contribute.html or gitwrite.html that

> > describes the exact commit message format being used.

> 

> Sure, I'm sending patch for that.


Thanks.  There are references to author timestamps there.  The date in a 
ChangeLog entry should always be a commit timestamp, not an author one, so 
author timestamps present either in commit messages or in the git commit 
metadata should be ignored, with only the committer timestamps from the 
git commit metadata being used when generating ChangeLog files.

-- 
Joseph S. Myers
joseph@codesourcery.com
Martin Liška May 15, 2020, 9:28 a.m. | #7
On 5/14/20 6:47 PM, Joseph Myers wrote:
> On Thu, 14 May 2020, Martin Liška wrote:

> 

>> On 5/13/20 7:53 PM, Joseph Myers wrote:

>>> On Wed, 13 May 2020, Martin Liška wrote:

>>>

>>>> I'm sending the gcc-changelog relates scripts which should be added to

>>>> contrib

>>>> folder. The patch contains:

>>>> - git_check_commit.py - checking script that verifies git message format

>>>

>>> We need a documentation patch to contribute.html or gitwrite.html that

>>> describes the exact commit message format being used.

>>

>> Sure, I'm sending patch for that.

> 

> Thanks.  There are references to author timestamps there.  The date in a

> ChangeLog entry should always be a commit timestamp, not an author one, so

> author timestamps present either in commit messages or in the git commit

> metadata should be ignored, with only the committer timestamps from the

> git commit metadata being used when generating ChangeLog files.


You are fully right, a committer date is what should be used.
Fixed in the documentation, note that the scripts use committed date.

Martin
diff --git a/htdocs/codingconventions.html b/htdocs/codingconventions.html
index f4732ef6..d2e73962 100644
--- a/htdocs/codingconventions.html
+++ b/htdocs/codingconventions.html
@@ -112,9 +112,14 @@ maintained and kept up to date.  In particular:</p>
 
 <h2 id="ChangeLogs">ChangeLogs</h2>
 
-<p>GCC requires ChangeLog entries for documentation changes; for the web
-pages (apart from <code>java/</code> and <code>libstdc++/</code>) the CVS
-commit logs are sufficient.</p>
+<p>
+ChangeLog entries are part of git commit messages and are automatically put
+into a corresponding ChangeLog file.  A ChangeLog template can be easily generated
+with <code>./contrib/mklog</code> script.  GCC offers a checking script that
+verifies a proper ChangeLog formatting (see <code>git gcc-verify</code> git alias).
+for a particular git commit.  The checking script covers most commonly used ChangeLog
+formats and the following paragraphs explain what it supports.
+</p>
 
 <p>See also what the <a
 href="http://www.gnu.org/prep/standards_toc.html">GNU Coding
@@ -124,19 +129,95 @@ in comments rather than the ChangeLog, though a single line overall
 description of the changes may be useful above the ChangeLog entry for
 a large batch of changes.</p>
 
-<p>For changes that are ported from another branch, we recommend to
-use a single entry whose body contains a verbatim copy of the original
-entries describing the changes on that branch, possibly preceded by a
-single-line overall description of the changes.</p>
+<h3>Components</h3>
+
+<ul>
+    <li><code class="other">git_description</code> - a leading text with git commit description</li>
+    <li><code class="other">committer_timestamp</code> - line with timestamp and an author name and email (2 spaces before and after name) <br>
+        example: <code class="other">2020-04-23␣␣Martin Liska␣␣&lt;mliska@suse.cz&gt;</code></li>
+    <li><code class="other">additional_author</code> - line with additional commit author name and email (starting with a tabular and 4 spaces) <br>
+        example: <code class="other">\t␣␣␣␣Martin Liska␣␣&lt;mliska@suse.cz&gt;</code></li>
+    <li><code class="other">changelog_location</code> - a location to a ChangeLog file <br>
+        supported formats: <code class="other">a/b/c/ChangeLog</code>, <code class="other">a/b/c/ChangeLog:</code>, <code class="other">a/b/c/</code> (where ChangeLog file lives in the folder), <code class="other">\ta/b/c/</code> and <code class="other">a/b/c</code></li>
+    <li><code class="other">pr_entry</code> - bug report reference <br>
+        example: <code class="other">\tPR component/12345</code></li>
+    <li><code class="other">changelog_file</code> - a modified file mentined in a ChangeLog:
+        supported formats: <code class="other">\t* a/b/c/file.c:</code>, <code class="other">\t* a/b/c/file.c (function):</code>, <code class="other">\t* a/b/c/file1.c, a/b/c/file2.c:</code></li>
+    <li><code class="other">changelog_file_comment</code> - line that follows a <code class="other">changelog_file</code> with description of changes in the file;
+        must start with <code class="other">\t</code></li>
+    <li><code class="other">co_authored_by</code> - <a href="https://help.github.com/en/github/committing-changes-to-your-project/creating-a-commit-with-multiple-authors">GitHub format</a> for a Co-Authored-By</li>
+</ul>
+
+<h3>Format rules</h3>
+
+<ul>
+    <li><code class="other">git_description</code> - optional; ends right before one of the other compoments is found</li>
+    <li><code class="other">committer_timestamp</code> - optional; when found before a <code class="other">changelog_file</code>, then it is added
+    to each changelog entry</li>
+    <li><code class="other">additional_author</code> - optional</li>
+    <li><code class="other">changelog_location</code> - optional; parser attempts to identify ChangeLog file based
+    on modified files; <code class="other">$changelog_location</code> belonging to a different ChangeLog must
+    be separated with an empty line</li>
+    <li><code class="other">pr_entry</code> - optional; can contain any number of PR entries</li>
+    <li><code class="other">changelog_file</code> - each <code>changelog_location</code> must contain at least one file</li>
+    <li><code class="other">changelog_file_comment</code> - optional</li>
+    <li><code class="other">co_authored_by</code> - optional, can contain more than one</li>
+</ul>
+
+<h3>Documented behaviour</h3>
+
+<ul>
+    <li>a missing <code class="other">changelog_location</code> file location can be deduced based on group of <code class="other">changelog_file</code>s</li>
+    <li>script automatically generates missing "New file." entries for files that are added in a commit</li>
+    <li>changed files that are not mentioned in a ChangeLog file generate an error</li>
+    <li>similarly for unchanged files that are mentioned in a ChangeLog file</li>
+    <li>a commit author and committer date stamp can be automatically deduced from a git commit - we recommend to use it</li>
+    <li><code class="other">co_authored_by</code> is added to each ChangeLog entry</li>
+    <li>a PR component is checked against list of valid components</li>
+    <li><code>ChangeLog</code> files, <code>DATESTAMP</code>, <code>BASE-VER</code> and <code>DEV-PHASE</code> can be modified only separately from other files</li>
+</ul>
 
-<p>There is no established convention on when ChangeLog entries are to
-be made for testsuite changes; see messages <a
-href="https://gcc.gnu.org/ml/gcc/2000-09/msg00287.html">1</a> and <a
-href="https://gcc.gnu.org/ml/gcc/2000-09/msg00290.html">2</a>.</p>
+<h3>Example patch</h3>
 
-<p>If your change fixes a PR, put <code>PR java/58</code> (where
-<code>java/58</code> is the actual number of the PR) at the top
-of the ChangeLog entry.</p>
+<pre><code>This patch adds a second movk pattern that models the instruction
+as a "normal" and/ior operation rather than an insertion.  It fixes
+the third insv_1.c failure in PR87763, which was a regression from
+GCC 8.
+
+2020-02-06  John Foo  &lt;john@example.com&gt;
+
+gcc/
+	PR target/87763
+	* config/aarch64/aarch64-protos.h (aarch64_movk_shift): Declare.
+	* config/aarch64/aarch64.c (aarch64_movk_shift): New function.
+	* config/aarch64/aarch64.md (aarch64_movk&lt;mode&gt;): New pattern.
+
+gcc/testsuite/
+	PR target/87763
+	* gcc.target/aarch64/movk_2.c: New test.
+
+Co-Authored-By: Jack Bar  &lt;jack@example.com&gt;
+</code></pre>
+
+<h3>Tokenized patch</h3>
+
+<pre>
+<code>$git_description
+
+$committer_timestamp
+
+$changelog_location
+$pr_entry
+$changelog_file
+$changelog_file
+$changelog_file
+
+$changelog_location
+$pr_entry
+$changelog_file
+
+$co_authored_by</code>
+</pre>
 
 <h2 id="Portability">Portability</h2>
 
@@ -201,7 +282,6 @@ minimize the number of function prototypes, by defining them before
 their first use.  Function prototypes should only be used when
 necessary, to break mutually recursive cycles.</p>
 
-
 <h2 id="Makefiles">Makefiles</h2>
 
 <p><code>touch</code> should never be used in GCC Makefiles.  Instead
diff --git a/htdocs/contribute.html b/htdocs/contribute.html
index 3d03b9d1..80a4470e 100644
--- a/htdocs/contribute.html
+++ b/htdocs/contribute.html
@@ -177,22 +177,10 @@ testcases cannot be added.
 
 <dt>ChangeLog</dt>
 <dd>
-A ChangeLog entry as plaintext; see the various ChangeLog files for
-format and content, and the <a href="codingconventions.html">GCC
+A ChangeLog entry as plaintext; see the <a href="codingconventions.html#ChangeLogs">GCC
 coding conventions</a> and <a
 href="http://www.gnu.org/prep/standards_toc.html">GNU Coding
-Standards</a> for further information.  The ChangeLog entries should
-be plaintext rather than part of the patch since the top of the
-ChangeLog changes rapidly and a patch to the ChangeLog would probably
-no longer apply by the time your patch is reviewed.
-If your change fixes a PR, put text in the ChangeLog entry mentioning
-the PR.  Our infrastructure understands how to
-extract this information and automatically append the commit log to
-the PR.  In order to be recognized, the text must fit a particular
-form.  It must start with "PR", and then must include the category
-and PR number.  For instance, <code>PR java/2369</code> is
-valid.  Multiple PRs can be mentioned in a single message.
-</dd>
+Standards</a> for further information.</dd>
 
 <dt>Bootstrapping and testing</dt>
 <dd>
diff --git a/htdocs/gitwrite.html b/htdocs/gitwrite.html
index 97d60870..791213a5 100644
--- a/htdocs/gitwrite.html
+++ b/htdocs/gitwrite.html
@@ -25,7 +25,6 @@ maintainers and significant developers.</p>
   <li><a href="#checkin">Checking in a change</a></li>
   <li><a href="#example">Example check-in session</a></li>
   <li><a href="#branches">Creating and using branches</a></li>
-  <li><a href="#changelog">git-merge-changelog</a></li>
   <li><a href="#vendor">Personal and Vendor branches</a></li>
   <li><a href="#account">Tips&amp;Tricks around your account</a></li>
 </ol>
@@ -237,9 +236,10 @@ pull</code>" before attempting a checkin; this will save you a little
 time if someone else has modified the source tree since the last time
 you synced your sources.</li>
 
-<li>Apply the patch to your local tree and update the ChangeLog file.
-Use the current date/time for the ChangeLog entry, not the time that
-the patch was submitted.</li>
+<li>Apply the patch to your local tree.  ChangeLog entries will be
+automatically added to the corresponding ChangeLog files based
+on the git commit message.  See the documentation of
+<a href="codingconventions.html#ChangeLogs">ChangeLog format</a>.</li>
 
 <li>Make sure to rebuild any generated files that would be affected by
 the patch.  Make sure to check them in along with the files explicitly
@@ -347,30 +347,6 @@ accordingly.  It may be easier to cherry-pick some smaller changes onto master
 don't need to <code>merge --squash</code> squash, but still need to make sure
 the commits on the branch satisfy the above rules for commits.
 
-<hr />
-<h2 id="changelog">git-merge-changelog</h2>
-
-git's native handling of ChangeLog merges is pretty bad, but there's a separate
-git-merge-changelog tool that improves things dramatically.  Some operating
-system distributions have a git-merge-changelog package already, or to build it
-by hand you can do
-
-<blockquote><pre>
-git clone git://git.savannah.gnu.org/gnulib.git
-cd gnulib
-./gnulib-tool --create-testdir --dir=/tmp/testdir123 git-merge-changelog
-cd /tmp/testdir123
-./configure
-make
-make install
-</pre></blockquote>
-And then to enable it, do
-<blockquote><pre>
-git config --global merge.merge-changelog.name "GNU-style ChangeLog merge driver"
-git config --global merge.merge-changelog.driver "git-merge-changelog %O %A %B"
-echo "ChangeLog*   merge=merge-changelog" >> $GCCSRCDIR/.git/info/attributes
-</pre></blockquote>
-
 <hr />
 <h2 id="vendor">Personal and vendor branches</h2>
 
@@ -457,6 +433,7 @@ repository:</p>
   </li>
   <li><i>gcc-descr</i> - Undocumented</li>
   <li><i>gcc-undescr</i> - Undocumented</li>
+  <li><i>gcc-verify</i> - Undocumented</li>
 </ul>
 
 <p>The final customization that the script makes is to add a diff rule so
Martin Liška May 19, 2020, 9:26 a.m. | #8
Hello.

We've just installed server git hooks that verify git messages
for a correct ChangeLog format. For a limited time period, please
still apply ChangeLog changes to the corresponding ChangeLog files.
We'll use it for comparison of auto-generated CangeLog entries.

The format is documented here:
https://gcc.gnu.org/codingconventions.html#ChangeLogs

And I would recommend to install the new 'git gcc-verify' hook from:
contrib/gcc-git-customization.sh

Feel free to contact me about future troubles you'll see.

Thanks,
Martin
H.J. Lu via Gcc-patches May 19, 2020, 10:19 p.m. | #9
On Tue, 19 May 2020 at 11:44, Martin Liška <mliska@suse.cz> wrote:
>

> Hello.

>

> We've just installed server git hooks that verify git messages

> for a correct ChangeLog format. For a limited time period, please

> still apply ChangeLog changes to the corresponding ChangeLog files.

> We'll use it for comparison of auto-generated CangeLog entries.

>

> The format is documented here:

> https://gcc.gnu.org/codingconventions.html#ChangeLogs

>

> And I would recommend to install the new 'git gcc-verify' hook from:

> contrib/gcc-git-customization.sh

>

> Feel free to contact me about future troubles you'll see.


The --allow-non-strict-mode option seems unnecessarily verbose. It's
not allowing non-strict mode, it's enabling it. Would --non-strict or
--relaxed be better?

And I don't understand the help text for it. 'Use non-strict mode
(change in both ChangeLog and other files.' It seems that non-strict
mode allows changes to certain "project files" that are not supposed
to be manually edited, but I can't correlate that to "change in both
ChangeLog and other files". It's also missing the closing parenthesis.

Would this patch make sense?
diff --git a/contrib/gcc-changelog/git_check_commit.py b/contrib/gcc-changelog/git_check_commit.py
index 8553c90a96f..d504be9dbde 100755
--- a/contrib/gcc-changelog/git_check_commit.py
+++ b/contrib/gcc-changelog/git_check_commit.py
@@ -28,9 +28,9 @@ parser.add_argument('-g', '--git-path', default='.',
                     help='Path to git repository')
 parser.add_argument('-p', '--print-changelog', action='store_true',
                     help='Print final changelog entires')
-parser.add_argument('-n', '--allow-non-strict-mode', action='store_true',
-                    help='Allow non-strict mode (change in both ChangeLog and '
-                    'other files.')
+parser.add_argument('-n', '--non-strict-mode', action='store_true',
+                    help='Use non-strict mode (allow changes in ChangeLog and '
+                    'other automatically updated files.')
 args = parser.parse_args()
 
 retval = 0
H.J. Lu via Gcc-patches May 19, 2020, 10:20 p.m. | #10
On Tue, 19 May 2020 at 23:19, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>

> On Tue, 19 May 2020 at 11:44, Martin Liška <mliska@suse.cz> wrote:

> >

> > Hello.

> >

> > We've just installed server git hooks that verify git messages

> > for a correct ChangeLog format. For a limited time period, please

> > still apply ChangeLog changes to the corresponding ChangeLog files.

> > We'll use it for comparison of auto-generated CangeLog entries.

> >

> > The format is documented here:

> > https://gcc.gnu.org/codingconventions.html#ChangeLogs

> >

> > And I would recommend to install the new 'git gcc-verify' hook from:

> > contrib/gcc-git-customization.sh

> >

> > Feel free to contact me about future troubles you'll see.

>

> The --allow-non-strict-mode option seems unnecessarily verbose. It's

> not allowing non-strict mode, it's enabling it. Would --non-strict or

> --relaxed be better?

>

> And I don't understand the help text for it. 'Use non-strict mode

> (change in both ChangeLog and other files.' It seems that non-strict

> mode allows changes to certain "project files" that are not supposed

> to be manually edited, but I can't correlate that to "change in both

> ChangeLog and other files". It's also missing the closing parenthesis.

>

> Would this patch make sense?


Or this one that actually adds the closing parenthesis :-)
diff --git a/contrib/gcc-changelog/git_check_commit.py b/contrib/gcc-changelog/git_check_commit.py
index 8553c90a96f..4fa2bb0b4a2 100755
--- a/contrib/gcc-changelog/git_check_commit.py
+++ b/contrib/gcc-changelog/git_check_commit.py
@@ -28,9 +28,9 @@ parser.add_argument('-g', '--git-path', default='.',
                     help='Path to git repository')
 parser.add_argument('-p', '--print-changelog', action='store_true',
                     help='Print final changelog entires')
-parser.add_argument('-n', '--allow-non-strict-mode', action='store_true',
-                    help='Allow non-strict mode (change in both ChangeLog and '
-                    'other files.')
+parser.add_argument('-n', '--non-strict-mode', action='store_true',
+                    help='Use non-strict mode (allow changes in ChangeLog and '
+                    'other automatically updated files).')
 args = parser.parse_args()
 
 retval = 0
Martin Liška May 20, 2020, 8:06 a.m. | #11
On 5/20/20 12:20 AM, Jonathan Wakely wrote:
> Or this one that actually adds the closing parenthesis


Thank you, it's definitely an improvement.

There's final version of the patch I've just applied.

Martin
From a55c1018c9d7c53b643203e7f71b06953fae86a1 Mon Sep 17 00:00:00 2001
From: Jonathan Wakely <jwakely@redhat.com>

Date: Wed, 20 May 2020 10:03:51 +0200
Subject: [PATCH] git_check_commit: shorted option name

contrib/ChangeLog:

2020-05-20  Martin Liska  <mliska@suse.cz>

	* gcc-changelog/git_check_commit.py: Change
	--allow-non-strict-mode to --non-strict-mode.
---
 contrib/gcc-changelog/git_check_commit.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/gcc-changelog/git_check_commit.py b/contrib/gcc-changelog/git_check_commit.py
index 8553c90a96f..2601ae4f613 100755
--- a/contrib/gcc-changelog/git_check_commit.py
+++ b/contrib/gcc-changelog/git_check_commit.py
@@ -28,14 +28,14 @@ parser.add_argument('-g', '--git-path', default='.',
                     help='Path to git repository')
 parser.add_argument('-p', '--print-changelog', action='store_true',
                     help='Print final changelog entires')
-parser.add_argument('-n', '--allow-non-strict-mode', action='store_true',
-                    help='Allow non-strict mode (change in both ChangeLog and '
-                    'other files.')
+parser.add_argument('-n', '--non-strict-mode', action='store_true',
+                    help='Use non-strict mode (allow changes in ChangeLog and '
+                    'other automatically updated files).')
 args = parser.parse_args()
 
 retval = 0
 for git_commit in parse_git_revisions(args.git_path, args.revisions,
-                                      not args.allow_non_strict_mode):
+                                      not args.non_strict_mode):
     res = 'OK' if git_commit.success else 'FAILED'
     print('Checking %s: %s' % (git_commit.hexsha, res))
     if git_commit.success:
-- 
2.26.2
Rainer Orth May 21, 2020, 3:14 p.m. | #12
Hi Martin,

> We've just installed server git hooks that verify git messages

> for a correct ChangeLog format. For a limited time period, please

> still apply ChangeLog changes to the corresponding ChangeLog files.

> We'll use it for comparison of auto-generated CangeLog entries.

>

> The format is documented here:

> https://gcc.gnu.org/codingconventions.html#ChangeLogs


two comments:

* Can you please avoid the use grey highlighting in that section?  Black
  script on a grey background is already hard to read for someone with
  reasonable vision.  I suspect it will be much harder for
  vision-impaired people.

* In changelog_location, you allow only (among others) "a/b/c/" and
  "\ta/b/c/".  Please also accept the "a/b/c:" and "\ta/b/c:" forms
  here: especially the second seems quite common.

Thanks.
        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
Martin Liška May 21, 2020, 3:19 p.m. | #13
On 5/21/20 5:14 PM, Rainer Orth wrote:
> Hi Martin,

> 

>> We've just installed server git hooks that verify git messages

>> for a correct ChangeLog format. For a limited time period, please

>> still apply ChangeLog changes to the corresponding ChangeLog files.

>> We'll use it for comparison of auto-generated CangeLog entries.

>>

>> The format is documented here:

>> https://gcc.gnu.org/codingconventions.html#ChangeLogs

> 

> two comments:

> 

> * Can you please avoid the use grey highlighting in that section?  Black

>    script on a grey background is already hard to read for someone with

>    reasonable vision.  I suspect it will be much harder for

>    vision-impaired people.


You are right, I fixed that.

> 

> * In changelog_location, you allow only (among others) "a/b/c/" and

>    "\ta/b/c/".  Please also accept the "a/b/c:" and "\ta/b/c:" forms

>    here: especially the second seems quite common.


Sure, can you please link some git revisions that use the format?

Thanks,
Martin

> 

> Thanks.

>          Rainer

>
Rainer Orth May 21, 2020, 3:37 p.m. | #14
Hi Martin,

>> two comments:

>>

>> * Can you please avoid the use grey highlighting in that section?  Black

>>    script on a grey background is already hard to read for someone with

>>    reasonable vision.  I suspect it will be much harder for

>>    vision-impaired people.

>

> You are right, I fixed that.


thanks.

>> * In changelog_location, you allow only (among others) "a/b/c/" and

>>    "\ta/b/c/".  Please also accept the "a/b/c:" and "\ta/b/c:" forms

>>    here: especially the second seems quite common.

>

> Sure, can you please link some git revisions that use the format?


Apart from using it myself ;-), I've seen it several times, but no
examples off-hand.  However, it seems only consistent with the forms
ending in /ChangeLog where you allow the trailing colon, too.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
H.J. Lu via Gcc-patches May 21, 2020, 6:52 p.m. | #15
Was there a decision somewhere to require ChangeLog entries for all
testcase changes now, as the hook is enforcing?  They were optional before.

remote: *** ChangeLog format failed:
remote: ERR: changed file not mentioned in a
ChangeLog:"gcc/testsuite/g++.dg/parse/error33.C"

On Thu, May 21, 2020 at 11:38 AM Rainer Orth <ro@cebitec.uni-bielefeld.de>
wrote:

> Hi Martin,

>

> >> two comments:

> >>

> >> * Can you please avoid the use grey highlighting in that section?  Black

> >>    script on a grey background is already hard to read for someone with

> >>    reasonable vision.  I suspect it will be much harder for

> >>    vision-impaired people.

> >

> > You are right, I fixed that.

>

> thanks.

>

> >> * In changelog_location, you allow only (among others) "a/b/c/" and

> >>    "\ta/b/c/".  Please also accept the "a/b/c:" and "\ta/b/c:" forms

> >>    here: especially the second seems quite common.

> >

> > Sure, can you please link some git revisions that use the format?

>

> Apart from using it myself ;-), I've seen it several times, but no

> examples off-hand.  However, it seems only consistent with the forms

> ending in /ChangeLog where you allow the trailing colon, too.

>

>         Rainer

>

> --

>

> -----------------------------------------------------------------------------

> Rainer Orth, Center for Biotechnology, Bielefeld University

>

>
H.J. Lu via Gcc-patches May 21, 2020, 6:56 p.m. | #16
On Thu, May 21, 2020 at 02:52:37PM -0400, Jason Merrill wrote:
> Was there a decision somewhere to require ChangeLog entries for all

> testcase changes now, as the hook is enforcing?  They were optional before.

> 

> remote: *** ChangeLog format failed:

> remote: ERR: changed file not mentioned in a

> ChangeLog:"gcc/testsuite/g++.dg/parse/error33.C"


They are optional for newly added testcases (even other new files); for that
it will add : New test. or something similar, Martin knows the details.

But right now they are not optional if an existing file is modified, because
in that case no script can (easily) find out what to say about it,
: Some change.
would be too useless/fuzzy.

	Jakub
Martin Liška May 21, 2020, 6:58 p.m. | #17
On 5/21/20 8:52 PM, Jason Merrill wrote:
> Was there a decision somewhere to require ChangeLog entries for all testcase changes now, as the hook is enforcing?  They were optional before.


Right now we ignore newly added test-case, these don't have to be mentioned.
Can you please attach the patch (git format-patch)?

Are you talking about modified or delete test-cases? If so, we can definitely
relax the rules..

Martin
H.J. Lu via Gcc-patches May 21, 2020, 7:51 p.m. | #18
On Thu, May 21, 2020 at 2:58 PM Martin Liška <mliska@suse.cz> wrote:

> On 5/21/20 8:52 PM, Jason Merrill wrote:

> > Was there a decision somewhere to require ChangeLog entries for all

> testcase changes now, as the hook is enforcing?  They were optional before.

>

> Right now we ignore newly added test-case, these don't have to be

> mentioned.

> Can you please attach the patch (git format-patch)?

>

> Are you talking about modified or delete test-cases? If so, we can

> definitely

> relax the rules..

>


Modified.  Adjustments to expected errors in testcases don't seem to me
worth documenting in a ChangeLog.
From c5a15303c57171b5b284b7a8ec0eb97f991779d6 Mon Sep 17 00:00:00 2001
From: Jason Merrill <jason@redhat.com>
Date: Thu, 21 May 2020 10:27:11 -0400
Subject: [PATCH 1/4] c++: Improve error-recovery for parms.
To: gcc-patches@gcc.gnu.org

If a parameter is erroneous, we currently drop it, leading to "too many
arguments" errors later.  Treating the function as (...) avoids those
errors.

gcc/cp/ChangeLog
2020-05-21  Jason Merrill  <jason@redhat.com>

	* decl.c (grokparms): Return NULL_TREE if any parms were erroneous.
---
 gcc/cp/decl.c                        | 18 +++++++++++++-----
 gcc/testsuite/g++.dg/parse/error33.C |  4 ++--
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 024ddc88a4c..a389579ee52 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13961,7 +13961,10 @@ grokparms (tree parmlist, tree *parms)
 	break;
 
       if (! decl || TREE_TYPE (decl) == error_mark_node)
-	continue;
+	{
+	  any_error = 1;
+	  continue;
+	}
 
       type = TREE_TYPE (decl);
       if (VOID_TYPE_P (type))
@@ -14014,7 +14017,8 @@ grokparms (tree parmlist, tree *parms)
 	      TREE_TYPE (decl) = type;
 	    }
 	  else if (abstract_virtuals_error (decl, type))
-	    any_error = 1;  /* Seems like a good idea.  */
+	    /* Ignore any default argument.  */
+	    init = NULL_TREE;
 	  else if (cxx_dialect < cxx17 && INDIRECT_TYPE_P (type))
 	    {
 	      /* Before C++17 DR 393:
@@ -14043,9 +14047,7 @@ grokparms (tree parmlist, tree *parms)
 			 decl, t);
 	    }
 
-	  if (any_error)
-	    init = NULL_TREE;
-	  else if (init && !processing_template_decl)
+	  if (init && !processing_template_decl)
 	    init = check_default_argument (decl, init, tf_warning_or_error);
 	}
 
@@ -14058,6 +14060,12 @@ grokparms (tree parmlist, tree *parms)
   if (parm)
     result = chainon (result, void_list_node);
   *parms = decls;
+  if (any_error)
+    result = NULL_TREE;
+
+  if (any_error)
+    /* We had parm errors, recover by giving the function (...) type.  */
+    result = NULL_TREE;
 
   return result;
 }
diff --git a/gcc/testsuite/g++.dg/parse/error33.C b/gcc/testsuite/g++.dg/parse/error33.C
index 0d25386a879..61b0cc3f2dc 100644
--- a/gcc/testsuite/g++.dg/parse/error33.C
+++ b/gcc/testsuite/g++.dg/parse/error33.C
@@ -8,9 +8,9 @@ struct A
 
 typedef void (A::T)(); /* { dg-error "15:typedef name may not be a nested" } */
 
-void bar(T); /* { dg-message "note: declared here" } */
+void bar(T);
 
 void baz()
 {
-  bar(&A::foo); /* { dg-error "too many arguments" } */
+  bar(&A::foo);
 }
Martin Liška May 21, 2020, 8:27 p.m. | #19
On 5/21/20 9:51 PM, Jason Merrill wrote:
> Modified.  Adjustments to expected errors in testcases don't seem to me worth documenting in a ChangeLog.


I see. As Jakub mentioned, I would keep the hook stricter for now.

Martin
H.J. Lu via Gcc-patches May 21, 2020, 9:01 p.m. | #20
On Thu, May 21, 2020 at 4:27 PM Martin Liška <mliska@suse.cz> wrote:

> On 5/21/20 9:51 PM, Jason Merrill wrote:

> > Modified.  Adjustments to expected errors in testcases don't seem to me

> worth documenting in a ChangeLog.

>

> I see. As Jakub mentioned, I would keep the hook stricter for now.

>


Why?  What is the use of requiring ChangeLog entries at all for these
changes?

Jason
Martin Liška May 21, 2020, 9:30 p.m. | #21
On 5/21/20 11:01 PM, Jason Merrill wrote:
> Why?  What is the use of requiring ChangeLog entries at all for these changes?


I must confirm a common test-suite ChangeLog entry is something like:

$ grep ':' gcc/testsuite/ChangeLog | sed 's/.*://' | sort | uniq -c | sort -n | tac | head -n 15
    6309  Likewise.
    1306  New test.
     231  New.
      68  New testcase.
      55
      54  Ditto.
      47  New file.
      33  Same.
      27  Move into ...
      24  New tests.
      21  Add typedef for int32_t.
      19  This.  Clean up
      17  Rename to...
      16  This.
      12  ...this.

$ grep ':' gcc/testsuite/ChangeLog-2019 | sed 's/.*://' | sort | uniq -c | sort -n | tac | head -n 15
    2981  Likewise.
    2287  New test.
     399  New testcase.
     263  Same.
     263  New.
     217  Ditto.
     111  Adjust.
      88  New file.
      62
      32  Require exceptions.
      30  Remove.
      25  New
      20  Update test.
      17  New tests.
      15  Add

$ grep ':' gcc/testsuite/ChangeLog-2018 | sed 's/.*://' | sort | uniq -c | sort -n | tac | head -n 15
    5071  Likewise.
    2071  New test.
     443  New.
     413  New testcase.
     395  Remove.
     256  Ditto.
     224  Same.
     108  New file.
      66  Likwise.
      65  Adjust.
      53
      52  Dito.
      39  Add -flinker-output=nolto-rel.
      32  New test case.
      26  Delete testcase.

So I'm open for relaxation of the rule.
What about the others?

Martin
H.J. Lu via Gcc-patches May 21, 2020, 10:12 p.m. | #22
On Tue, May 19, 2020 at 2:26 AM Martin Liška <mliska@suse.cz> wrote:
>

> We've just installed server git hooks that verify git messages

> for a correct ChangeLog format. For a limited time period, please

> still apply ChangeLog changes to the corresponding ChangeLog files.

> We'll use it for comparison of auto-generated CangeLog entries.

>

> The format is documented here:

> https://gcc.gnu.org/codingconventions.html#ChangeLogs

>

> And I would recommend to install the new 'git gcc-verify' hook from:

> contrib/gcc-git-customization.sh

>

> Feel free to contact me about future troubles you'll see.


Hi, this unfortunately breaks gccgo development.  Significant parts of
the gccgo sources are simply copied from other repositories.  Those
other repositories do not use ChangeLog files.  The git commit hook
should not require ChangeLog files for those changes.  And, when the
time comes, no ChangeLog files should be created for changes in those
directories.

The directories in question are

gcc/go/gofrontend
libgo
gcc/testsuite/go.test/test

This is as documented in the README.gcc files in those directories.

How can I exempt those directories from the server hook?  Right now,
as far as I can tell, I cannot commit Go changes.  I get

remote: *** ChangeLog format failed:
remote: ERR: cannot find a ChangeLog location in message
remote:
remote: Please see: https://gcc.gnu.org/codingconventions.html#ChangeLogs
remote:
remote: error: hook declined to update refs/heads/master
To git+ssh://gcc.gnu.org/git/gcc
 ! [remote rejected]         master -> master (hook declined)
error: failed to push some refs to 'git+ssh://gcc.gnu.org/git/gcc'

Thanks.

Ian
H.J. Lu via Gcc-patches May 22, 2020, 4:57 a.m. | #23
On Thu, May 21, 2020 at 03:12:21PM -0700, Ian Lance Taylor via Gcc wrote:
> Hi, this unfortunately breaks gccgo development.  Significant parts of

> the gccgo sources are simply copied from other repositories.  Those

> other repositories do not use ChangeLog files.  The git commit hook

> should not require ChangeLog files for those changes.  And, when the

> time comes, no ChangeLog files should be created for changes in those

> directories.

> 

> The directories in question are

> 

> gcc/go/gofrontend

> libgo

> gcc/testsuite/go.test/test


The script has:
ignored_prefixes = [
    'gcc/d/dmd/',
    'gcc/go/frontend/',
    'libgo/',
    'libphobos/libdruntime',
    'libphobos/src/',
    'libsanitizer/',
    ]
so perhaps it just misses gcc/testsuite/go.test/test ?
Or what exact files you've changed in your script?

	Jakub
Martin Liška May 22, 2020, 6:05 a.m. | #24
On 5/22/20 6:57 AM, Jakub Jelinek wrote:
> so perhaps it just misses gcc/testsuite/go.test/test ?


Hello.

I've just added the location to ignored locations.

> Or what exact files you've changed in your script?


@Ian: Please send us patch with git format-patch.
@Jakub: Can you please sync up the script to the server hooks? I'll
be AFK till Monday.

Martin
Richard Earnshaw May 22, 2020, 11:04 a.m. | #25
On 22/05/2020 05:57, Jakub Jelinek wrote:
> On Thu, May 21, 2020 at 03:12:21PM -0700, Ian Lance Taylor via Gcc wrote:

>> Hi, this unfortunately breaks gccgo development.  Significant parts of

>> the gccgo sources are simply copied from other repositories.  Those

>> other repositories do not use ChangeLog files.  The git commit hook

>> should not require ChangeLog files for those changes.  And, when the

>> time comes, no ChangeLog files should be created for changes in those

>> directories.

>>

>> The directories in question are

>>

>> gcc/go/gofrontend

>> libgo

>> gcc/testsuite/go.test/test

> 

> The script has:

> ignored_prefixes = [

>     'gcc/d/dmd/',

>     'gcc/go/frontend/',


The directory is gcc/go/gofrontend

so it's missing 'go' from frontend.

>     'libgo/',

>     'libphobos/libdruntime',

>     'libphobos/src/',

>     'libsanitizer/',

>     ]

> so perhaps it just misses gcc/testsuite/go.test/test ?

> Or what exact files you've changed in your script?

> 

> 	Jakub

> 


R.
H.J. Lu via Gcc-patches May 22, 2020, 11:11 a.m. | #26
On Fri, May 22, 2020 at 12:04:10PM +0100, Richard Earnshaw wrote:
> >> The directories in question are

> >>

> >> gcc/go/gofrontend

> >> libgo

> >> gcc/testsuite/go.test/test

> > 

> > The script has:

> > ignored_prefixes = [

> >     'gcc/d/dmd/',

> >     'gcc/go/frontend/',

> 

> The directory is gcc/go/gofrontend

> 

> so it's missing 'go' from frontend.


Thanks for spotting.  I believe Martin said he will be afk
today, so I've fixed it for him and committed as obvious and
am going to install into git-hooks now too.

diff --git a/contrib/ChangeLog b/contrib/ChangeLog
index 7b61bb8915b..64a0db18e58 100644
--- a/contrib/ChangeLog
+++ b/contrib/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-22  Jakub Jelinek  <jakub@redhat.com>
+
+	* gcc-changelog/git_commit.py: Add trailing / to
+	gcc/testsuite/go.test/test and replace gcc/go/frontend/
+	with gcc/go/gofrontend/ in ignored locations.
+
 2020-05-22  Martin Liska  <mliska@suse.cz>
 
 	* gcc-changelog/git_commit.py: Add gcc/testsuite/go.test/test
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index ba9f5ce9650..8c5fa2c0fc9 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -127,8 +127,8 @@ bug_components = set([
 
 ignored_prefixes = [
     'gcc/d/dmd/',
-    'gcc/go/frontend/',
-    'gcc/testsuite/go.test/test',
+    'gcc/go/gofrontend/',
+    'gcc/testsuite/go.test/test/',
     'libgo/',
     'libphobos/libdruntime',
     'libphobos/src/',

	Jakub
H.J. Lu via Gcc-patches May 22, 2020, 7:37 p.m. | #27
On Fri, May 22, 2020 at 4:11 AM Jakub Jelinek <jakub@redhat.com> wrote:
>

> On Fri, May 22, 2020 at 12:04:10PM +0100, Richard Earnshaw wrote:

> > >> The directories in question are

> > >>

> > >> gcc/go/gofrontend

> > >> libgo

> > >> gcc/testsuite/go.test/test

> > >

> > > The script has:

> > > ignored_prefixes = [

> > >     'gcc/d/dmd/',

> > >     'gcc/go/frontend/',

> >

> > The directory is gcc/go/gofrontend

> >

> > so it's missing 'go' from frontend.

>

> Thanks for spotting.  I believe Martin said he will be afk

> today, so I've fixed it for him and committed as obvious and

> am going to install into git-hooks now too.

>

> diff --git a/contrib/ChangeLog b/contrib/ChangeLog

> index 7b61bb8915b..64a0db18e58 100644

> --- a/contrib/ChangeLog

> +++ b/contrib/ChangeLog

> @@ -1,3 +1,9 @@

> +2020-05-22  Jakub Jelinek  <jakub@redhat.com>

> +

> +       * gcc-changelog/git_commit.py: Add trailing / to

> +       gcc/testsuite/go.test/test and replace gcc/go/frontend/

> +       with gcc/go/gofrontend/ in ignored locations.

> +

>  2020-05-22  Martin Liska  <mliska@suse.cz>

>

>         * gcc-changelog/git_commit.py: Add gcc/testsuite/go.test/test

> diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py

> index ba9f5ce9650..8c5fa2c0fc9 100755

> --- a/contrib/gcc-changelog/git_commit.py

> +++ b/contrib/gcc-changelog/git_commit.py

> @@ -127,8 +127,8 @@ bug_components = set([

>

>  ignored_prefixes = [

>      'gcc/d/dmd/',

> -    'gcc/go/frontend/',

> -    'gcc/testsuite/go.test/test',

> +    'gcc/go/gofrontend/',

> +    'gcc/testsuite/go.test/test/',

>      'libgo/',

>      'libphobos/libdruntime',

>      'libphobos/src/',


Thanks for looking into this.

Unfortunately, my push is still failing.  I'm not sure why.

remote: *** ChangeLog format failed:
remote: ERR: cannot find a ChangeLog location in message
remote:
remote: Please see: https://gcc.gnu.org/codingconventions.html#ChangeLogs
remote:
remote: error: hook declined to update refs/heads/master
To git+ssh://gcc.gnu.org/git/gcc
 ! [remote rejected]         master -> master (hook declined)
error: failed to push some refs to 'git+ssh://gcc.gnu.org/git/gcc'


I've attached the output of "git format-patch -k 1 --stdout", in case
that helps.

Ian
From 81994eab700da7fea6644541c163aa0f0f3b8cf1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <chigot.c@gmail.com>
Date: Tue, 19 May 2020 16:03:54 +0200
Subject: libgo: update x/sys/cpu after gccgo support added

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/234597
---
 gcc/go/gofrontend/MERGE                       |  2 +-
 .../sys/cpu/{cpu_aix_ppc64.go => cpu_aix.go}  |  2 +-
 .../golang.org/x/sys/cpu/syscall_aix_gccgo.go | 27 +++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
 rename libgo/go/golang.org/x/sys/cpu/{cpu_aix_ppc64.go => cpu_aix.go} (96%)
 create mode 100644 libgo/go/golang.org/x/sys/cpu/syscall_aix_gccgo.go

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index bc9c1f07eda..284374820b0 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-bc27341f245a5cc54ac7530d037a609db72b677c
+ea58b8491064fbed18a220571a3043c38dccf7c7
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/golang.org/x/sys/cpu/cpu_aix_ppc64.go b/libgo/go/golang.org/x/sys/cpu/cpu_aix.go
similarity index 96%
rename from libgo/go/golang.org/x/sys/cpu/cpu_aix_ppc64.go
rename to libgo/go/golang.org/x/sys/cpu/cpu_aix.go
index b0ede112d4e..02d03129e50 100644
--- a/libgo/go/golang.org/x/sys/cpu/cpu_aix_ppc64.go
+++ b/libgo/go/golang.org/x/sys/cpu/cpu_aix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix,ppc64
+// +build aix
 
 package cpu
 
diff --git a/libgo/go/golang.org/x/sys/cpu/syscall_aix_gccgo.go b/libgo/go/golang.org/x/sys/cpu/syscall_aix_gccgo.go
new file mode 100644
index 00000000000..2609cc49ae7
--- /dev/null
+++ b/libgo/go/golang.org/x/sys/cpu/syscall_aix_gccgo.go
@@ -0,0 +1,27 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Recreate a getsystemcfg syscall handler instead of
+// using the one provided by x/sys/unix to avoid having
+// the dependency between them. (See golang.org/issue/32102)
+// Morover, this file will be used during the building of
+// gccgo's libgo and thus must not use a CGo method.
+
+// +build aix
+// +build gccgo
+
+package cpu
+
+import (
+	"syscall"
+)
+
+//extern getsystemcfg
+func gccgoGetsystemcfg(label uint32) (r uint64)
+
+func callgetsystemcfg(label int) (r1 uintptr, e1 syscall.Errno) {
+	r1 = uintptr(gccgoGetsystemcfg(uint32(label)))
+	e1 = syscall.GetErrno()
+	return
+}
H.J. Lu via Gcc-patches May 22, 2020, 7:47 p.m. | #28
On Fri, May 22, 2020 at 12:37:29PM -0700, Ian Lance Taylor wrote:
> Thanks for looking into this.

> 

> Unfortunately, my push is still failing.  I'm not sure why.

> 

> remote: *** ChangeLog format failed:

> remote: ERR: cannot find a ChangeLog location in message

> remote:

> remote: Please see: https://gcc.gnu.org/codingconventions.html#ChangeLogs

> remote:

> remote: error: hook declined to update refs/heads/master

> To git+ssh://gcc.gnu.org/git/gcc

>  ! [remote rejected]         master -> master (hook declined)

> error: failed to push some refs to 'git+ssh://gcc.gnu.org/git/gcc'

> 

> 

> I've attached the output of "git format-patch -k 1 --stdout", in case

> that helps.


Bet the script first looks for the ChangeLog entry and only considers the
ignored prefixes if it finds files in the patch that are not mentioned in
the ChangeLog entry.  So, if you say modified gcc/go/whatever.cc and had
ChangeLog entry for that and not for the files you've changed, it would be
ok.

So, I think before emitting the above message, it should look through the
patch and if it finds all files in ignored prefixes, it should just not to
do anything.

We'll need it e.g. for the DATESTAMP bump job too which only modifies those
files too and doesn't write ChangeLog entry for that.

I'm sorry but I don't know the script well enough to fix it quickly, will
defer to Martin as the author.

Can you wait with the commit until Monday?  If not, I could just temporarily
disable this for your commit.

	Jakub
H.J. Lu via Gcc-patches May 22, 2020, 10:14 p.m. | #29
On Fri, May 22, 2020 at 12:48 PM Jakub Jelinek <jakub@redhat.com> wrote:
>

> On Fri, May 22, 2020 at 12:37:29PM -0700, Ian Lance Taylor wrote:

> > Thanks for looking into this.

> >

> > Unfortunately, my push is still failing.  I'm not sure why.

> >

> > remote: *** ChangeLog format failed:

> > remote: ERR: cannot find a ChangeLog location in message

> > remote:

> > remote: Please see: https://gcc.gnu.org/codingconventions.html#ChangeLogs

> > remote:

> > remote: error: hook declined to update refs/heads/master

> > To git+ssh://gcc.gnu.org/git/gcc

> >  ! [remote rejected]         master -> master (hook declined)

> > error: failed to push some refs to 'git+ssh://gcc.gnu.org/git/gcc'

> >

> >

> > I've attached the output of "git format-patch -k 1 --stdout", in case

> > that helps.

>

> Bet the script first looks for the ChangeLog entry and only considers the

> ignored prefixes if it finds files in the patch that are not mentioned in

> the ChangeLog entry.  So, if you say modified gcc/go/whatever.cc and had

> ChangeLog entry for that and not for the files you've changed, it would be

> ok.

>

> So, I think before emitting the above message, it should look through the

> patch and if it finds all files in ignored prefixes, it should just not to

> do anything.

>

> We'll need it e.g. for the DATESTAMP bump job too which only modifies those

> files too and doesn't write ChangeLog entry for that.

>

> I'm sorry but I don't know the script well enough to fix it quickly, will

> defer to Martin as the author.

>

> Can you wait with the commit until Monday?  If not, I could just temporarily

> disable this for your commit.


Sure, I can wait.  Thanks for looking at it.

Ian
Martin Liška May 25, 2020, 7:48 a.m. | #30
On 5/23/20 12:14 AM, Ian Lance Taylor wrote:
> Sure, I can wait.  Thanks for looking at it.


Hello.

Thank you for patience. There's a patch that fixes that,
I'm going to install it.

Martin
From 76e18b91250f265a37d85063860fb38aa8f6aac3 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>

Date: Mon, 25 May 2020 09:40:50 +0200
Subject: [PATCH] Allow only ignored files in ChangeLog entries.

contrib/ChangeLog:

2020-05-25  Martin Liska  <mliska@suse.cz>

	* gcc-changelog/git_commit.py: Add trailing '/'
	for libdruntime.  Allow empty changelog for
	only ignored files.
	* gcc-changelog/test_email.py: New test for go
	patch in ignored location.
	* gcc-changelog/test_patches.txt: Add test.
---
 contrib/gcc-changelog/git_commit.py    |  5 +--
 contrib/gcc-changelog/test_email.py    |  4 +++
 contrib/gcc-changelog/test_patches.txt | 43 ++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 8c5fa2c0fc9..2cfdbc83d09 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -130,7 +130,7 @@ ignored_prefixes = [
     'gcc/go/gofrontend/',
     'gcc/testsuite/go.test/test/',
     'libgo/',
-    'libphobos/libdruntime',
+    'libphobos/libdruntime/',
     'libphobos/src/',
     'libsanitizer/',
     ]
@@ -233,7 +233,8 @@ class GitCommit:
 
         project_files = [f for f in self.modified_files
                          if self.is_changelog_filename(f[0])
-                         or f[0] in misc_files]
+                         or f[0] in misc_files
+                         or self.in_ignored_location(f[0])]
         if len(project_files) == len(self.modified_files):
             # All modified files are only MISC files
             return
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index d522e6ef7e3..aa516c6e6d1 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -276,3 +276,7 @@ class TestGccChangelog(unittest.TestCase):
     def test_dr_entry(self):
         email = self.from_patch_glob('0001-c-C-20-DR-2237.patch')
         assert email.changelog_entries[0].prs == ['DR 2237']
+
+    def test_changes_only_in_ignored_location(self):
+        email = self.from_patch_glob('0001-go-in-ignored-location.patch')
+        assert not email.errors
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index 3445c3d9f11..58fd81c85c9 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -2568,3 +2568,46 @@ index a6a5d975af3..a8082d39aca 100644
 @@ -1 +1,2 @@
 
 +
+
+=== 0001-go-in-ignored-location.patch ===
+From 81994eab700da7fea6644541c163aa0f0f3b8cf1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <chigot.c@gmail.com>
+Date: Tue, 19 May 2020 16:03:54 +0200
+Subject: libgo: update x/sys/cpu after gccgo support added
+
+Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/234597
+---
+ gcc/go/gofrontend/MERGE                       |  2 +-
+ .../sys/cpu/{cpu_aix_ppc64.go => cpu_aix.go}  |  2 +-
+ .../golang.org/x/sys/cpu/syscall_aix_gccgo.go | 27 +++++++++++++++++++
+ 3 files changed, 29 insertions(+), 2 deletions(-)
+ rename libgo/go/golang.org/x/sys/cpu/{cpu_aix_ppc64.go => cpu_aix.go} (96%)
+ create mode 100644 libgo/go/golang.org/x/sys/cpu/syscall_aix_gccgo.go
+
+diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
+index bc9c1f07eda..284374820b0 100644
+--- a/gcc/go/gofrontend/MERGE
++++ b/gcc/go/gofrontend/MERGE
+@@ -1 +1,2 @@
+
++
+diff --git a/libgo/go/golang.org/x/sys/cpu/cpu_aix_ppc64.go b/libgo/go/golang.org/x/sys/cpu/cpu_aix.go
+similarity index 96%
+rename from libgo/go/golang.org/x/sys/cpu/cpu_aix_ppc64.go
+rename to libgo/go/golang.org/x/sys/cpu/cpu_aix.go
+index b0ede112d4e..02d03129e50 100644
+--- a/libgo/go/golang.org/x/sys/cpu/cpu_aix_ppc64.go
++++ b/libgo/go/golang.org/x/sys/cpu/cpu_aix.go
+@@ -1 +1,2 @@
+
++
+diff --git a/libgo/go/golang.org/x/sys/cpu/syscall_aix_gccgo.go b/libgo/go/golang.org/x/sys/cpu/syscall_aix_gccgo.go
+new file mode 100644
+index 00000000000..2609cc49ae7
+--- /dev/null
++++ b/libgo/go/golang.org/x/sys/cpu/syscall_aix_gccgo.go
+@@ -0,0 +1 @@
++
+
+-- 
+2.27.0.rc0.183.gde8f92d652-goog
-- 
2.26.2
Martin Liška May 25, 2020, 8:25 a.m. | #31
On 5/21/20 5:14 PM, Rainer Orth wrote:
> * In changelog_location, you allow only (among others) "a/b/c/" and

>    "\ta/b/c/".  Please also accept the "a/b/c:" and "\ta/b/c:" forms

>    here: especially the second seems quite common.


Ok, I believe these formats are supported as well. Feel free to mention
some git revisions that are not recognized.

Thanks,
Martin
H.J. Lu via Gcc-patches May 25, 2020, 8:44 p.m. | #32
On Mon, May 25, 2020 at 12:48 AM Martin Liška <mliska@suse.cz> wrote:
>

> On 5/23/20 12:14 AM, Ian Lance Taylor wrote:

> > Sure, I can wait.  Thanks for looking at it.

>

> Hello.

>

> Thank you for patience. There's a patch that fixes that,

> I'm going to install it.


Thanks.  I was able to push my change to master.

Ian
Alexandre Oliva May 26, 2020, 5:31 a.m. | #33
On May 25, 2020, Martin Liška <mliska@suse.cz> wrote:

> On 5/21/20 5:14 PM, Rainer Orth wrote:

>> * In changelog_location, you allow only (among others) "a/b/c/" and

>> "\ta/b/c/".  Please also accept the "a/b/c:" and "\ta/b/c:" forms

>> here: especially the second seems quite common.


> Ok, I believe these formats are supported as well. Feel free to mention

> some git revisions that are not recognized.


I've long used the following syntax to start ChangeLog entries:

for  <some/dir>/ChangeLog

It was introduced over 20 years ago, with the (so far never formally
released) GNU CVS-Utilities.  Among other goodies, there were scripts to
turn diffs for ChangeLog files into the above format, and vice-versa,
that I've used to this day.  It went through cvs, svn and git.  It would
be quite nice if I could keep on using it with GCC.

The patch below seems to be enough to pass gcc-verify, and to recognize
and print the expected ChangeLog files.  I suppose I'll have to adjust
the formatting to be able to push it, but, aside from that, is it ok to
install?

Do any hooks need to be adjusted to match?


I'm also a little concerned about '*/ChangeLog.*' files.  Are we no
longer supposed to introduce them, or new ChangeLog entries to them?  Or
should the scripts be extended to cover them?


for  contrib/ChangeLog

	* gcc-changelog/git_commit.py (changelog_regex): Accept optional
	'for' prefix.

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 2cfdbc8..b8362c1 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -144,7 +144,7 @@ misc_files = [
 author_line_regex = \
         re.compile(r'^(?P<datetime>\d{4}-\d{2}-\d{2})\ {2}(?P<name>.*  <.*>)')
 additional_author_regex = re.compile(r'^\t(?P<spaces>\ *)?(?P<name>.*  <.*>)')
-changelog_regex = re.compile(r'^([a-z0-9+-/]*)/ChangeLog:?')
+changelog_regex = re.compile(r'^(?:[fF]or +)([a-z0-9+-/]*)/ChangeLog:?')
 pr_regex = re.compile(r'\tPR (?P<component>[a-z+-]+\/)?([0-9]+)$')
 dr_regex = re.compile(r'\tDR ([0-9]+)$')
 star_prefix_regex = re.compile(r'\t\*(?P<spaces>\ *)(?P<content>.*)')



-- 
Alexandre Oliva, freedom fighter    he/him    https://FSFLA.org/blogs/lxo/
Free Software Evangelist              Stallman was right, but he's left :(
GNU Toolchain Engineer           Live long and free, and prosper ethically
Martin Liška May 26, 2020, 6:13 a.m. | #34
On 5/26/20 7:31 AM, Alexandre Oliva wrote:
> On May 25, 2020, Martin Liška <mliska@suse.cz> wrote:

> 

>> On 5/21/20 5:14 PM, Rainer Orth wrote:

>>> * In changelog_location, you allow only (among others) "a/b/c/" and

>>> "\ta/b/c/".  Please also accept the "a/b/c:" and "\ta/b/c:" forms

>>> here: especially the second seems quite common.

> 

>> Ok, I believe these formats are supported as well. Feel free to mention

>> some git revisions that are not recognized.


Hello.

> 

> I've long used the following syntax to start ChangeLog entries:

> 

> for  <some/dir>/ChangeLog


Ah, it's new for me.

> 

> It was introduced over 20 years ago, with the (so far never formally

> released) GNU CVS-Utilities.  Among other goodies, there were scripts to

> turn diffs for ChangeLog files into the above format, and vice-versa,

> that I've used to this day.  It went through cvs, svn and git.  It would

> be quite nice if I could keep on using it with GCC.


Sure. Starting from now, you don't need to put ChangeLog entries to their
corresponding files, it will be done automatically.

> 

> The patch below seems to be enough to pass gcc-verify, and to recognize

> and print the expected ChangeLog files.  I suppose I'll have to adjust

> the formatting to be able to push it, but, aside from that, is it ok to

> install?


I'm fine with the patch. Alternative approach is to start using
./contrib/mklog.py (a.k.a. git mklog).

> 

> Do any hooks need to be adjusted to match?


Yes, we sync the script from the GCC repository.

> 

> 

> I'm also a little concerned about '*/ChangeLog.*' files.  Are we no

> longer supposed to introduce them, or new ChangeLog entries to them?  Or

> should the scripts be extended to cover them?


Right now we cover only ChangeLog files, so e.g. ChangeLog.dataflow is not affected
(and checked). For newly added ChangeLog files, we can add them, but they must first
appear in the git_commit.py script where we list all allowed locations.

Martin

> 

> 

> for  contrib/ChangeLog

> 

> 	* gcc-changelog/git_commit.py (changelog_regex): Accept optional

> 	'for' prefix.

> 

> diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py

> index 2cfdbc8..b8362c1 100755

> --- a/contrib/gcc-changelog/git_commit.py

> +++ b/contrib/gcc-changelog/git_commit.py

> @@ -144,7 +144,7 @@ misc_files = [

>   author_line_regex = \

>           re.compile(r'^(?P<datetime>\d{4}-\d{2}-\d{2})\ {2}(?P<name>.*  <.*>)')

>   additional_author_regex = re.compile(r'^\t(?P<spaces>\ *)?(?P<name>.*  <.*>)')

> -changelog_regex = re.compile(r'^([a-z0-9+-/]*)/ChangeLog:?')

> +changelog_regex = re.compile(r'^(?:[fF]or +)([a-z0-9+-/]*)/ChangeLog:?')

>   pr_regex = re.compile(r'\tPR (?P<component>[a-z+-]+\/)?([0-9]+)$')

>   dr_regex = re.compile(r'\tDR ([0-9]+)$')

>   star_prefix_regex = re.compile(r'\t\*(?P<spaces>\ *)(?P<content>.*)')

> 

> 

>
Alexandre Oliva May 26, 2020, 7:24 a.m. | #35
Hi, Martin,

On May 26, 2020, Martin Liška <mliska@suse.cz> wrote:

>> I've long used the following syntax to start ChangeLog entries:

>> 

>> for  <some/dir>/ChangeLog


> Ah, it's new for me.


>> 

>> It was introduced over 20 years ago, with the (so far never formally

>> released) GNU CVS-Utilities.  Among other goodies, there were scripts to

>> turn diffs for ChangeLog files into the above format, and vice-versa,

>> that I've used to this day.  It went through cvs, svn and git.  It would

>> be quite nice if I could keep on using it with GCC.             ^^


For clarity, I meant the syntax in the last sentence above.  The
ChangeLog-related functionality in the scripts now becomes mostly
obsolete.

>> The patch below seems to be enough to pass gcc-verify, and to recognize

>> and print the expected ChangeLog files.


'cept it broke cases without 'for' because I missed a '?' in the
regexp.  Good thing I had to adjust for the old format to be able to
push it ;-)  2x0 ;-)

>> Do any hooks need to be adjusted to match?


> Yes, we sync the script from the GCC repository.


Here's what I'm about to push


accept for dir/ChangeLog entries

From: Alexandre Oliva <oliva@gnu.org>


I've long introduced ChangeLog entries as "for  dir/ChangeLog", a
format adopted by GNU CVS-Utilities some 20 years ago.  My commits
have been formatted like this forever.

This patch makes it acceptable for git gcc-verify.


contrib/ChangeLog:

	* gcc-changelog/git_commit.py (changelog_regex): Accept optional
	'for' prefix.
---
 contrib/gcc-changelog/git_commit.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 2cfdbc8..732a9bd8 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -144,7 +144,7 @@ misc_files = [
 author_line_regex = \
         re.compile(r'^(?P<datetime>\d{4}-\d{2}-\d{2})\ {2}(?P<name>.*  <.*>)')
 additional_author_regex = re.compile(r'^\t(?P<spaces>\ *)?(?P<name>.*  <.*>)')
-changelog_regex = re.compile(r'^([a-z0-9+-/]*)/ChangeLog:?')
+changelog_regex = re.compile(r'^(?:[fF]or +)?([a-z0-9+-/]*)/ChangeLog:?')
 pr_regex = re.compile(r'\tPR (?P<component>[a-z+-]+\/)?([0-9]+)$')
 dr_regex = re.compile(r'\tDR ([0-9]+)$')
 star_prefix_regex = re.compile(r'\t\*(?P<spaces>\ *)(?P<content>.*)')


-- 
Alexandre Oliva, freedom fighter    he/him    https://FSFLA.org/blogs/lxo/
Free Software Evangelist              Stallman was right, but he's left :(
GNU Toolchain Engineer           Live long and free, and prosper ethically
Martin Liška July 8, 2020, 1:25 p.m. | #36
On 5/13/20 7:53 PM, Joseph Myers wrote:
>   See the issues

> I filed athttps://github.com/AdaCore/git-hooks/issues  for the existing

> custom GCC changes and the pull request

> https://github.com/AdaCore/git-hooks/pull/12  to bring in implementations

> of many of those features (not sure if it covers everything or not).


Hey Joseph.

If I see correctly, the pull request was merged.
Are we now in a position where we can separate the GCC-specific
ChangeLog check in gcc-hooks? If so, can you please guide me
a bit?

Thanks,
Martin

Patch

From 6367837722c62930c9e00e9aa82073d24813a4c1 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 11 May 2020 15:24:16 +0200
Subject: [PATCH] Add gcc-changelog hook for commit message format.

---
 hooks/git_commit.py        | 535 +++++++++++++++++++++++++++++++++++++
 hooks/pre_commit_checks.py |  29 +-
 hooks/updates/__init__.py  |   2 +-
 3 files changed, 563 insertions(+), 3 deletions(-)
 create mode 100755 hooks/git_commit.py

diff --git a/hooks/git_commit.py b/hooks/git_commit.py
new file mode 100755
index 0000000..5214cc3
--- /dev/null
+++ b/hooks/git_commit.py
@@ -0,0 +1,535 @@ 
+#!/usr/bin/env python3
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 3, or (at your option) any later
+# version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.  */
+
+import os
+import re
+
+changelog_locations = set([
+    'config',
+    'contrib',
+    'contrib/header-tools',
+    'contrib/reghunt',
+    'contrib/regression',
+    'fixincludes',
+    'gcc/ada',
+    'gcc/analyzer',
+    'gcc/brig',
+    'gcc/c',
+    'gcc/c-family',
+    'gcc',
+    'gcc/cp',
+    'gcc/d',
+    'gcc/fortran',
+    'gcc/go',
+    'gcc/jit',
+    'gcc/lto',
+    'gcc/objc',
+    'gcc/objcp',
+    'gcc/po',
+    'gcc/testsuite',
+    'gnattools',
+    'gotools',
+    'include',
+    'intl',
+    'libada',
+    'libatomic',
+    'libbacktrace',
+    'libcc1',
+    'libcpp',
+    'libcpp/po',
+    'libdecnumber',
+    'libffi',
+    'libgcc',
+    'libgcc/config/avr/libf7',
+    'libgcc/config/libbid',
+    'libgfortran',
+    'libgomp',
+    'libhsail-rt',
+    'libiberty',
+    'libitm',
+    'libobjc',
+    'liboffloadmic',
+    'libphobos',
+    'libquadmath',
+    'libsanitizer',
+    'libssp',
+    'libstdc++-v3',
+    'libvtv',
+    'lto-plugin',
+    'maintainer-scripts',
+    'zlib'])
+
+bug_components = set([
+    'ada',
+    'analyzer',
+    'boehm-gc',
+    'bootstrap',
+    'c',
+    'c++',
+    'd',
+    'debug',
+    'demangler',
+    'driver',
+    'fastjar',
+    'fortran',
+    'gcov-profile',
+    'go',
+    'hsa',
+    'inline-asm',
+    'ipa',
+    'java',
+    'jit',
+    'libbacktrace',
+    'libf2c',
+    'libffi',
+    'libfortran',
+    'libgcc',
+    'libgcj',
+    'libgomp',
+    'libitm',
+    'libobjc',
+    'libquadmath',
+    'libstdc++',
+    'lto',
+    'middle-end',
+    'modula2',
+    'objc',
+    'objc++',
+    'other',
+    'pch',
+    'pending',
+    'plugins',
+    'preprocessor',
+    'regression',
+    'rtl-optimization',
+    'sanitizer',
+    'spam',
+    'target',
+    'testsuite',
+    'translation',
+    'tree-optimization',
+    'web'])
+
+ignored_prefixes = [
+    'gcc/d/dmd/',
+    'gcc/go/frontend/',
+    'libgo/',
+    'libphobos/libdruntime',
+    'libphobos/src/',
+    'libsanitizer/',
+    ]
+
+misc_files = [
+    'gcc/DATESTAMP',
+    'gcc/BASE-VER',
+    'gcc/DEV-PHASE'
+    ]
+
+author_line_regex = \
+        re.compile(r'^(?P<datetime>\d{4}-\d{2}-\d{2})\ {2}(?P<name>.*  <.*>)')
+additional_author_regex = re.compile(r'^\t(?P<spaces>\ *)?(?P<name>.*  <.*>)')
+changelog_regex = re.compile(r'^([a-z0-9+-/]*)/ChangeLog:?')
+pr_regex = re.compile(r'\tPR (?P<component>[a-z+-]+\/)?([0-9]+)$')
+star_prefix_regex = re.compile(r'\t\*(?P<spaces>\ *)(?P<content>.*)')
+
+LINE_LIMIT = 100
+TAB_WIDTH = 8
+CO_AUTHORED_BY_PREFIX = 'co-authored-by: '
+
+
+class Error:
+    def __init__(self, message, line=None):
+        self.message = message
+        self.line = line
+
+    def __repr__(self):
+        s = self.message
+        if self.line:
+            s += ':"%s"' % self.line
+        return s
+
+
+class ChangeLogEntry:
+    def __init__(self, folder, authors, prs):
+        self.folder = folder
+        # Python2 has not 'copy' function
+        self.author_lines = list(authors)
+        self.initial_prs = list(prs)
+        self.prs = list(prs)
+        self.lines = []
+
+    @property
+    def files(self):
+        files = []
+        for line in self.lines:
+            m = star_prefix_regex.match(line)
+            if m:
+                line = m.group('content')
+                if '(' in line:
+                    line = line[:line.index('(')]
+                if ':' in line:
+                    line = line[:line.index(':')]
+                for file in line.split(','):
+                    file = file.strip()
+                    if file:
+                        files.append(file)
+        return files
+
+    @property
+    def datetime(self):
+        for author in self.author_lines:
+            if author[1]:
+                return author[1]
+        return None
+
+    @property
+    def authors(self):
+        return [author_line[0] for author_line in self.author_lines]
+
+    @property
+    def is_empty(self):
+        return not self.lines and self.prs == self.initial_prs
+
+
+class GitCommit:
+    def __init__(self, hexsha, date, author, body, modified_files,
+                 strict=True):
+        self.hexsha = hexsha
+        self.lines = body
+        self.modified_files = modified_files
+        self.message = None
+        self.changes = None
+        self.changelog_entries = []
+        self.errors = []
+        self.date = date
+        self.author = author
+        self.top_level_authors = []
+        self.co_authors = []
+        self.top_level_prs = []
+
+        project_files = [f for f in self.modified_files
+                         if self.is_changelog_filename(f[0])
+                         or f[0] in misc_files]
+        if len(project_files) == len(self.modified_files):
+            # All modified files are only MISC files
+            return
+        elif project_files and strict:
+            self.errors.append(Error('ChangeLog, DATESTAMP, BASE-VER and '
+                                     'DEV-PHASE updates should be done '
+                                     'separately from normal commits'))
+            return
+
+        self.parse_lines()
+        if self.changes:
+            self.parse_changelog()
+            self.deduce_changelog_locations()
+            if not self.errors:
+                self.check_mentioned_files()
+                self.check_for_correct_changelog()
+
+    @property
+    def success(self):
+        return not self.errors
+
+    @property
+    def new_files(self):
+        return [x[0] for x in self.modified_files if x[1] == 'A']
+
+    @classmethod
+    def is_changelog_filename(cls, path):
+        return path.endswith('/ChangeLog') or path == 'ChangeLog'
+
+    @classmethod
+    def find_changelog_location(cls, name):
+        if name.startswith('\t'):
+            name = name[1:]
+        if name.endswith(':'):
+            name = name[:-1]
+        if name.endswith('/'):
+            name = name[:-1]
+        return name if name in changelog_locations else None
+
+    @classmethod
+    def format_git_author(cls, author):
+        assert '<' in author
+        return author.replace('<', ' <')
+
+    @classmethod
+    def parse_git_name_status(cls, string):
+        modified_files = []
+        for entry in string.split('\n'):
+            parts = entry.split('\t')
+            t = parts[0]
+            if t == 'A' or t == 'D' or t == 'M':
+                modified_files.append((parts[1], t))
+            elif t == 'R':
+                modified_files.append((parts[1], 'D'))
+                modified_files.append((parts[2], 'A'))
+        return modified_files
+
+    def parse_lines(self):
+        body = self.lines
+
+        for i, b in enumerate(body):
+            if not b:
+                continue
+            if (changelog_regex.match(b) or self.find_changelog_location(b)
+                    or star_prefix_regex.match(b) or pr_regex.match(b)
+                    or author_line_regex.match(b)):
+                self.changes = body[i:]
+                return
+        self.errors.append(Error('cannot find a ChangeLog location in '
+                                 'message'))
+
+    def parse_changelog(self):
+        last_entry = None
+        will_deduce = False
+        for line in self.changes:
+            if not line:
+                if last_entry and will_deduce:
+                    last_entry = None
+                continue
+            if line != line.rstrip():
+                self.errors.append(Error('trailing whitespace', line))
+            if len(line.replace('\t', ' ' * TAB_WIDTH)) > LINE_LIMIT:
+                self.errors.append(Error('line limit exceeds %d characters'
+                                         % LINE_LIMIT, line))
+            m = changelog_regex.match(line)
+            if m:
+                last_entry = ChangeLogEntry(m.group(1), self.top_level_authors,
+                                            self.top_level_prs)
+                self.changelog_entries.append(last_entry)
+            elif self.find_changelog_location(line):
+                last_entry = ChangeLogEntry(self.find_changelog_location(line),
+                                            self.top_level_authors,
+                                            self.top_level_prs)
+                self.changelog_entries.append(last_entry)
+            else:
+                author_tuple = None
+                pr_line = None
+                if author_line_regex.match(line):
+                    m = author_line_regex.match(line)
+                    author_tuple = (m.group('name'), m.group('datetime'))
+                elif additional_author_regex.match(line):
+                    m = additional_author_regex.match(line)
+                    if len(m.group('spaces')) != 4:
+                        msg = 'additional author must prepend with tab ' \
+                              'and 4 spaces'
+                        self.errors.append(Error(msg, line))
+                    else:
+                        author_tuple = (m.group('name'), None)
+                elif pr_regex.match(line):
+                    component = pr_regex.match(line).group('component')
+                    if not component:
+                        self.errors.append(Error('missing PR component', line))
+                        continue
+                    elif not component[:-1] in bug_components:
+                        self.errors.append(Error('invalid PR component', line))
+                        continue
+                    else:
+                        pr_line = line.lstrip()
+
+                if line.lower().startswith(CO_AUTHORED_BY_PREFIX):
+                    name = line[len(CO_AUTHORED_BY_PREFIX):]
+                    author = self.format_git_author(name)
+                    self.co_authors.append(author)
+                    continue
+
+                # ChangeLog name will be deduced later
+                if not last_entry:
+                    if author_tuple:
+                        self.top_level_authors.append(author_tuple)
+                        continue
+                    elif pr_line:
+                        # append to top_level_prs only when we haven't met
+                        # a ChangeLog entry
+                        if (pr_line not in self.top_level_prs
+                                and not self.changelog_entries):
+                            self.top_level_prs.append(pr_line)
+                        continue
+                    else:
+                        last_entry = ChangeLogEntry(None,
+                                                    self.top_level_authors,
+                                                    self.top_level_prs)
+                        self.changelog_entries.append(last_entry)
+                        will_deduce = True
+                elif author_tuple:
+                    last_entry.author_lines.append(author_tuple)
+                    continue
+
+                if not line.startswith('\t'):
+                    err = Error('line should start with a tab', line)
+                    self.errors.append(err)
+                elif pr_line:
+                    last_entry.prs.append(pr_line)
+                else:
+                    m = star_prefix_regex.match(line)
+                    if m:
+                        if len(m.group('spaces')) != 1:
+                            err = Error('one space should follow asterisk',
+                                        line)
+                            self.errors.append(err)
+                        else:
+                            last_entry.lines.append(line)
+                    else:
+                        if last_entry.is_empty:
+                            msg = 'first line should start with a tab, ' \
+                                  'asterisk and space'
+                            self.errors.append(Error(msg, line))
+                        else:
+                            last_entry.lines.append(line)
+
+    def get_file_changelog_location(self, changelog_file):
+        for file in self.modified_files:
+            if file[0] == changelog_file:
+                # root ChangeLog file
+                return ''
+            index = file[0].find('/' + changelog_file)
+            if index != -1:
+                return file[0][:index]
+        return None
+
+    def deduce_changelog_locations(self):
+        for entry in self.changelog_entries:
+            if not entry.folder:
+                changelog = None
+                for file in entry.files:
+                    location = self.get_file_changelog_location(file)
+                    if (location == ''
+                       or (location and location in changelog_locations)):
+                        if changelog and changelog != location:
+                            msg = 'could not deduce ChangeLog file, ' \
+                                  'not unique location'
+                            self.errors.append(Error(msg))
+                            return
+                        changelog = location
+                if changelog is not None:
+                    entry.folder = changelog
+                else:
+                    msg = 'could not deduce ChangeLog file'
+                    self.errors.append(Error(msg))
+
+    @classmethod
+    def in_ignored_location(cls, path):
+        for ignored in ignored_prefixes:
+            if path.startswith(ignored):
+                return True
+        return False
+
+    @classmethod
+    def get_changelog_by_path(cls, path):
+        components = path.split('/')
+        while components:
+            if '/'.join(components) in changelog_locations:
+                break
+            components = components[:-1]
+        return '/'.join(components)
+
+    def check_mentioned_files(self):
+        folder_count = len([x.folder for x in self.changelog_entries])
+        assert folder_count == len(self.changelog_entries)
+
+        mentioned_files = set()
+        for entry in self.changelog_entries:
+            if not entry.files:
+                msg = 'ChangeLog must contain a file entry'
+                self.errors.append(Error(msg, entry.folder))
+            assert not entry.folder.endswith('/')
+            for file in entry.files:
+                if not self.is_changelog_filename(file):
+                    mentioned_files.add(os.path.join(entry.folder, file))
+
+        cand = [x[0] for x in self.modified_files
+                if not self.is_changelog_filename(x[0])]
+        changed_files = set(cand)
+        for file in sorted(mentioned_files - changed_files):
+            self.errors.append(Error('file not changed in a patch', file))
+        for file in sorted(changed_files - mentioned_files):
+            if not self.in_ignored_location(file):
+                if file in self.new_files:
+                    changelog_location = self.get_changelog_by_path(file)
+                    # Python2: we cannot use next(filter(...))
+                    entries = filter(lambda x: x.folder == changelog_location,
+                                     self.changelog_entries)
+                    entries = list(entries)
+                    entry = entries[0] if entries else None
+                    if not entry:
+                        prs = self.top_level_prs
+                        if not prs:
+                            # if all ChangeLog entries have identical PRs
+                            # then use them
+                            prs = self.changelog_entries[0].prs
+                            for entry in self.changelog_entries:
+                                if entry.prs != prs:
+                                    prs = []
+                                    break
+                        entry = ChangeLogEntry(changelog_location,
+                                               self.top_level_authors,
+                                               prs)
+                        self.changelog_entries.append(entry)
+                    # strip prefix of the file
+                    assert file.startswith(entry.folder)
+                    file = file[len(entry.folder):].lstrip('/')
+                    entry.lines.append('\t* %s: New file.' % file)
+                else:
+                    msg = 'changed file not mentioned in a ChangeLog'
+                    self.errors.append(Error(msg, file))
+
+    def check_for_correct_changelog(self):
+        for entry in self.changelog_entries:
+            for file in entry.files:
+                full_path = os.path.join(entry.folder, file)
+                changelog_location = self.get_changelog_by_path(full_path)
+                if changelog_location != entry.folder:
+                    msg = 'wrong ChangeLog location "%s", should be "%s"'
+                    err = Error(msg % (entry.folder, changelog_location), file)
+                    self.errors.append(err)
+
+    def to_changelog_entries(self):
+        for entry in self.changelog_entries:
+            output = ''
+            timestamp = entry.datetime
+            if not timestamp:
+                timestamp = self.date.strftime('%Y-%m-%d')
+            authors = entry.authors if entry.authors else [self.author]
+            # add Co-Authored-By authors to all ChangeLog entries
+            for author in self.co_authors:
+                if author not in authors:
+                    authors.append(author)
+
+            for i, author in enumerate(authors):
+                if i == 0:
+                    output += '%s  %s\n' % (timestamp, author)
+                else:
+                    output += '\t    %s\n' % author
+            output += '\n'
+            for pr in entry.prs:
+                output += '\t%s\n' % pr
+            for line in entry.lines:
+                output += line + '\n'
+            yield (entry.folder, output.rstrip())
+
+    def print_output(self):
+        for entry, output in self.to_changelog_entries():
+            print('------ %s/ChangeLog ------ ' % entry)
+            print(output)
+
+    def print_errors(self):
+        print('Errors:')
+        for error in self.errors:
+            print(error)
diff --git a/hooks/pre_commit_checks.py b/hooks/pre_commit_checks.py
index b3546ba..dbdc269 100644
--- a/hooks/pre_commit_checks.py
+++ b/hooks/pre_commit_checks.py
@@ -3,6 +3,9 @@  from pipes import quote
 import re
 from subprocess import Popen, PIPE, STDOUT
 
+from git_commit import GitCommit
+from datetime import datetime
+
 from config import git_config
 from errors import InvalidUpdate
 from git import git, diff_tree, file_exists
@@ -326,8 +329,27 @@  def check_missing_ticket_number(rev, raw_rh):
         'Subject: %s' % raw_rh[0],
         ])
 
+def verify_changelog_format(rev, raw_body):
+    author = git.show(rev, format='%ae  <%aN>', no_patch=True)
+    committed_date = git.show(rev, format='%ct', no_patch=True)
+    changed_files = git.diff('%s~..%s' % (rev, rev), name_status=True)
+
+    date = datetime.utcfromtimestamp(int(committed_date))
+    # TODO: enable strict mode
+    git_commit = GitCommit(date, author, raw_body,
+                           GitCommit.parse_git_name_status(changed_files),
+                           strict=False)
 
-def check_revision_history(rev):
+    if git_commit.success:
+        # OK
+        pass
+    else:
+        message = 'ChangeLog format failed:\n'
+        for error in git_commit.errors:
+            message += 'ERR: %s\n' % error
+        raise InvalidUpdate(message)
+
+def check_revision_history(rev, project_name, short_ref_name):
     """Apply pre-commit checks to the commit's revision history.
 
     Raise InvalidUpdate if one or more style violation are detected.
@@ -370,7 +392,10 @@  def check_revision_history(rev):
                 'from SVN, not in new git commits.  If this is a cherry-pick '
                 'of a commit done in SVN, remove the From-SVN: line from '
                 'the commit message before pushing.')
-
+    if (len(raw_body) >= 1
+        and (short_ref_name == 'master'
+             or short_ref_name.startswith('releases/gcc-'))):
+        verify_changelog_format(rev, raw_body)
 
 def check_filename_collisions(rev):
     """raise InvalidUpdate if the name of two files only differ in casing.
diff --git a/hooks/updates/__init__.py b/hooks/updates/__init__.py
index 25bfb18..e47145f 100644
--- a/hooks/updates/__init__.py
+++ b/hooks/updates/__init__.py
@@ -263,7 +263,7 @@  class AbstractUpdate(object):
         if do_rh_style_checks:
             for commit in added:
                 if not commit.pre_existing_p:
-                    check_revision_history(commit.rev)
+                    check_revision_history(commit.rev, self.email_info.project_name, self.short_ref_name)
 
         reject_merge_commits = (
             self.search_config_option_list('hooks.reject-merge-commits')
-- 
2.26.2