]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - contrib/git-backport.py
Update copyright years.
[thirdparty/gcc.git] / contrib / git-backport.py
index 3a9413dcd274637dd42e74587fdca8d64a4bb8d8..331deb91e563d103899eb1ec05d4f5d676e739de 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-# Copyright (C) 2020 Free Software Foundation, Inc.
+# Copyright (C) 2020-2024 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 #
 # Boston, MA 02110-1301, USA.
 
 import argparse
+import os
 import subprocess
 
+script_folder = os.path.dirname(os.path.abspath(__file__))
+fixup_script = os.path.join(script_folder, 'git-fix-changelog.py')
+
 if __name__ == '__main__':
-    parser = argparse.ArgumentParser(description='Backport a git revision and '
-                                     'stash all ChangeLog files.')
+    parser = argparse.ArgumentParser(description='Backport a git revision.')
     parser.add_argument('revision', help='Revision')
     args = parser.parse_args()
 
-    r = subprocess.run('git cherry-pick -x %s' % args.revision, shell=True)
-    if r.returncode == 0:
-        cmd = 'git show --name-only --pretty="" -- "*ChangeLog"'
-        changelogs = subprocess.check_output(cmd, shell=True, encoding='utf8')
-        changelogs = changelogs.strip()
-        if changelogs:
-            for changelog in changelogs.split('\n'):
-                subprocess.check_output('git checkout HEAD~ %s' % changelog,
-                                        shell=True)
-        subprocess.check_output('git commit --amend --no-edit', shell=True)
-    else:
-        # 1) remove all ChangeLog files from conflicts
-        out = subprocess.check_output('git diff --name-only --diff-filter=U',
-                                      shell=True,
-                                      encoding='utf8')
-        conflicts = out.strip().split('\n')
-        changelogs = [c for c in conflicts if c.endswith('ChangeLog')]
-        if changelogs:
-            cmd = 'git checkout --theirs %s' % '\n'.join(changelogs)
-            subprocess.check_output(cmd, shell=True)
-        # 2) remove all ChangeLog files from index
-        cmd = 'git diff --name-only --diff-filter=M HEAD'
-        out = subprocess.check_output(cmd, shell=True, encoding='utf8')
-        out = out.strip().split('\n')
-        modified = [c for c in out if c.endswith('ChangeLog')]
-        for m in modified:
-            subprocess.check_output('git reset %s' % m, shell=True)
-            subprocess.check_output('git checkout %s' % m, shell=True)
-
-        # try to continue
-        if len(conflicts) == len(changelogs):
-            cmd = 'git -c core.editor=true cherry-pick --continue'
-            subprocess.check_output(cmd, shell=True)
-        else:
-            print('Please resolve all remaining file conflicts.')
+    subprocess.run('git cherry-pick -x %s' % args.revision, shell=True)
+    subprocess.run(fixup_script, shell=True)