public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Robin Dapp <rdapp.gcc@gmail.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>, mliska@suse.cz
Subject: [PATCH] mklog.py: Add --commit option.
Date: Thu, 11 May 2023 10:29:16 +0200	[thread overview]
Message-ID: <ada6da15-ba5e-1959-91ae-3ed9c44faf1f@gmail.com> (raw)

Hi,

this patch allows mklog.py to be called with a commit hash directly.
So, instead of

 git show <commit> | git gcc-mklog

 git gcc-mklog --commit <commit>

can be used.

When no <commit> is given but --commit is specified, HEAD is used
instead.  The behavior without --commit is the same as before.

Is that useful/OK?  I find that option a bit easier to work with.

Regards
 Robin

contrib/ChangeLog:

	* mklog.py:  Add optional --commit <commit> argument.
---
 contrib/mklog.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/contrib/mklog.py b/contrib/mklog.py
index 777212c98d7..25a3b6c0757 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -358,13 +358,23 @@ if __name__ == '__main__':
                              'file')
     parser.add_argument('--update-copyright', action='store_true',
                         help='Update copyright in ChangeLog files')
+    parser.add_argument('--commit', const='HEAD', nargs='?',
+                        help='Use a specific commit instead of a '
+                             'patch file or stdin. (essentially git show '
+                             'commit-id | git gcc-mklog)')
     args = parser.parse_args()
     if args.input == '-':
         args.input = None
     if args.directory:
         root = args.directory
 
-    data = open(args.input, newline='\n') if args.input else sys.stdin
+    if args.commit:
+        args.input = None
+        data = subprocess.check_output('git show {}'.format(args.commit),
+                                       shell=True, encoding='utf8').strip()
+    else:
+        data = open(args.input, newline='\n') if args.input else sys.stdin
+
     if args.update_copyright:
         update_copyright(data)
     else:
-- 
2.40.0


             reply	other threads:[~2023-05-11  8:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11  8:29 Robin Dapp [this message]
2023-05-11 14:46 ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ada6da15-ba5e-1959-91ae-3ed9c44faf1f@gmail.com \
    --to=rdapp.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).