From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CDAB3394740B for ; Thu, 27 Jan 2022 15:35:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CDAB3394740B Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-Vlu-Q0zePbuusNLsBKY-CQ-1; Thu, 27 Jan 2022 10:35:18 -0500 X-MC-Unique: Vlu-Q0zePbuusNLsBKY-CQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8FCDF8145E4; Thu, 27 Jan 2022 15:35:17 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15F5284A26; Thu, 27 Jan 2022 15:35:16 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 20RFZEei1577752 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 27 Jan 2022 16:35:14 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 20RFZDxM1577751; Thu, 27 Jan 2022 16:35:13 +0100 Date: Thu, 27 Jan 2022 16:35:13 +0100 From: Jakub Jelinek To: Martin =?utf-8?B?TGnFoWth?= Cc: Martin Jambor , Jonathan Wakely , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] contrib: Put gcc-descr and gcc-undescr to file. Message-ID: <20220127153513.GI2646553@tucnak> Reply-To: Jakub Jelinek References: <7e803eb3-d9df-99de-490d-823c1ffe29d7@suse.cz> <20211008111246.GF304296@tucnak> <11400b93-b2bb-6133-88f7-20219433f2a7@suse.cz> <12d44ac0-8849-466c-9749-b4e1e7168ac7@suse.cz> <1e75173a-801c-738f-ba3e-ee7c7483986b@suse.cz> <767afbf4-3de5-b74f-45f9-b4ce7d9a8dee@suse.cz> <28f9be5c-c9a7-9e33-1ba0-49579695c912@suse.cz> MIME-Version: 1.0 In-Reply-To: <28f9be5c-c9a7-9e33-1ba0-49579695c912@suse.cz> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jan 2022 15:35:24 -0000 On Thu, Jan 27, 2022 at 04:06:05PM +0100, Martin Liška wrote: > I've finished Martin's work and put the 2 aliases into files. The git-undescr.sh is basically > unchanged, while I added better option parsing for git-descr.sh script so that it supports: > > $ git gcc-descr > r12-6895-g14f339894db6ca > > $ git gcc-descr HEAD~10 > r12-6886-geaa59070343326 > > $ git gcc-descr HEAD~10 --long > r12-6886-geaa5907034332649c918f0579da805b6e786aa47 > > $ git gcc-descr --short HEAD~10 --long > r12-6886 > > $ git gcc-descr --short --short --long HEAD~10 > r12-6886 > > Ready to be installed? For backwards compatibility, I'd prefer --full to be an alias to --long, and maybe the --short handling should short=yes; long=no and similarly --long/--full handling should long=yes; short=no so that --short --long is --long and --long --short is --short. Otherwise LGTM. > From feb3f83724cd0764f7ad3fbd1504c0d43266c88a Mon Sep 17 00:00:00 2001 > From: Martin Liska > Date: Thu, 27 Jan 2022 16:01:55 +0100 > Subject: [PATCH] contrib: Put gcc-descr and gcc-undescr to file. > > contrib/ChangeLog: > > * git-descr.sh: New file. > * git-undescr.sh: New file. > Support optional arguments --long, --short and default > to 14 characters of git hash. > > contrib/ChangeLog: > > * gcc-git-customization.sh: Use the created files. > * git-descr.sh: New file. > * git-undescr.sh: New file. > > Co-Authored-By: Martin Jambor > --- > contrib/gcc-git-customization.sh | 4 ++-- > contrib/git-descr.sh | 37 ++++++++++++++++++++++++++++++++ > contrib/git-undescr.sh | 13 +++++++++++ > 3 files changed, 52 insertions(+), 2 deletions(-) > create mode 100755 contrib/git-descr.sh > create mode 100755 contrib/git-undescr.sh > > diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh > index 2eec17937af..b24948d9874 100755 > --- a/contrib/gcc-git-customization.sh > +++ b/contrib/gcc-git-customization.sh > @@ -22,8 +22,8 @@ git config alias.svn-rev '!f() { rev=$1; shift; git log --all --grep="^From-SVN: > > # Add git commands to convert git commit to monotonically increasing revision number > # and vice versa > -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-descr '!f() { "`git rev-parse --show-toplevel`/contrib/git-descr.sh" $@; } ; f' > +git config alias.gcc-undescr '!f() { "`git rev-parse --show-toplevel`/contrib/git-undescr.sh" $@; } ; f' > > git config alias.gcc-verify '!f() { "`git rev-parse --show-toplevel`/contrib/gcc-changelog/git_check_commit.py" $@; } ; f' > git config alias.gcc-backport '!f() { "`git rev-parse --show-toplevel`/contrib/git-backport.py" $@; } ; f' > diff --git a/contrib/git-descr.sh b/contrib/git-descr.sh > new file mode 100755 > index 00000000000..0d3e42940b3 > --- /dev/null > +++ b/contrib/git-descr.sh > @@ -0,0 +1,37 @@ > +#!/bin/sh > + > +# Script to describe a GCC revision based on git hash > + > +short=no > +long=no > +c=master > + > +for arg in "$@" > +do > + case "$arg" in > + --short) short=yes > + ;; > + --long) long=yes > + ;; > + *) c=$arg > + esac > +done > + > +if test x$short = xyes; then > + 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'); > +elif test x$long = xyes; then > + r=$(git describe --all --abbrev=40 --match 'basepoints/gcc-[0-9]*' $c | sed -n 's,^\(tags/\)\?basepoints/gcc-,r,p') > +else > + r=$(git describe --all --abbrev=14 --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 $c); > +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; > diff --git a/contrib/git-undescr.sh b/contrib/git-undescr.sh > new file mode 100755 > index 00000000000..7d2efe1a8e7 > --- /dev/null > +++ b/contrib/git-undescr.sh > @@ -0,0 +1,13 @@ > +#!/bin/sh > + > +# Script to undescribe a GCC revision > + > +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); > -- > 2.34.1 > Jakub