gcc-changelog: fix when somebody reverts a backport

Message ID 60f6f6cf-d408-021a-4731-566cd064b069@suse.cz
State New
Headers show
Series
  • gcc-changelog: fix when somebody reverts a backport
Related show

Commit Message

Martin Liška July 23, 2020, 8:43 a.m.
It's going to fix git commit 76641cd8b53128e1a962f1313ba75acf0855fd00,
where we not correctly print:

git gcc-verify 76641cd8b53128e1a962f1313ba75acf0855fd00 -p
Checking 76641cd8b53128e1a962f1313ba75acf0855fd00: OK
------ gcc/ChangeLog ------
2020-07-15  Richard Biener  <rguenther@suse.de>

	Revert:
	2020-07-14  Matthias Klose  <doko@ubuntu.com>

	PR lto/95604
	* lto-wrapper.c (merge_and_complain): Add decoded options as parameter,
	error on different values for -fcf-protection.
	(append_compiler_options): Pass -fcf-protection option.
	(find_and_merge_options): Add decoded options as parameter,
	pass decoded_options to merge_and_complain.
	(run_gcc): Pass decoded options to find_and_merge_options.
	* lto-opts.c (lto_write_options): Pass -fcf-protection option.

instead of:

git gcc-verify 76641cd8b53128e1a962f1313ba75acf0855fd00 -p
Checking 76641cd8b53128e1a962f1313ba75acf0855fd00: OK
------ gcc/ChangeLog ------
2020-07-14  Matthias Klose  <doko@ubuntu.com>

	Backported from master:
	2020-07-14  Matthias Klose  <doko@ubuntu.com>

	PR lto/95604
	* lto-wrapper.c (merge_and_complain): Add decoded options as parameter,
	error on different values for -fcf-protection.
	(append_compiler_options): Pass -fcf-protection option.
	(find_and_merge_options): Add decoded options as parameter,
	pass decoded_options to merge_and_complain.
	(run_gcc): Pass decoded options to find_and_merge_options.
	* lto-opts.c (lto_write_options): Pass -fcf-protection option.

I compared 500 revision on master and gcc-10 branch that's the only difference.
I'm going to install it.

Martin

contrib/ChangeLog:

	* gcc-changelog/git_commit.py: When reverting a backport,
	we should print only Revert header.
---
  contrib/gcc-changelog/git_commit.py | 19 ++++++++++---------
  1 file changed, 10 insertions(+), 9 deletions(-)

-- 
2.27.0

Patch

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 827976c2f84..5a9cc4c7563 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -628,7 +628,11 @@  class GitCommit:
          for entry in self.changelog_entries:
              output = ''
              timestamp = entry.datetime
-            if self.cherry_pick_commit:
+            if self.revert_commit:
+                timestamp = current_timestamp
+                orig_date = self.original_info.date
+                current_timestamp = orig_date.strftime(DATE_FORMAT)
+            elif self.cherry_pick_commit:
                  info = self.commit_to_info_hook(self.cherry_pick_commit)
                  # it can happen that it is a cherry-pick for a different
                  # repository
@@ -636,10 +640,6 @@  class GitCommit:
                      timestamp = info.date.strftime(DATE_FORMAT)
                  else:
                      timestamp = current_timestamp
-            elif self.revert_commit:
-                timestamp = current_timestamp
-                orig_date = self.original_info.date
-                current_timestamp = orig_date.strftime(DATE_FORMAT)
              elif not timestamp or use_commit_ts:
                  timestamp = current_timestamp
              authors = entry.authors if entry.authors else [self.info.author]
@@ -649,12 +649,13 @@  class GitCommit:
                      authors.append(author)
  
              if self.cherry_pick_commit or self.revert_commit:
-                output += self.format_authors_in_changelog([self.info.author],
+                original_author = self.original_info.author
+                output += self.format_authors_in_changelog([original_author],
                                                             current_timestamp)
-                if self.cherry_pick_commit:
-                    output += '\tBackported from master:\n'
-                else:
+                if self.revert_commit:
                      output += '\tRevert:\n'
+                else:
+                    output += '\tBackported from master:\n'
                  output += self.format_authors_in_changelog(authors,
                                                             timestamp, '\t')
              else: