diff mbox series

[v2] gcc_update: use human readable name for revision string in gcc/REVISION

Message ID 8735se1r4b.fsf_-_@depni.sinp.msu.ru
State New
Headers show
Series [v2] gcc_update: use human readable name for revision string in gcc/REVISION | expand

Commit Message

Serge Belyshev July 16, 2021, 10:37 a.m. UTC
Based on discussion I've chosen open-coded version without commit hash.

>> > > ...  Perhaps rename the r, o, rr and m temporaries.

I like it better with short names, there is no other code in that
script to clash with.  (Also, two adjacent case branches for hg and svn
are essentialy dead now).

>> ...  Perhaps also replace both HEAD occurences with $revision

not sure about that: should not they be exactly equivalent in all cases?

---
gcc_update: use human readable name for revision string in gcc/REVISION

contrib/Changelog:

	* gcc_update: derive human readable name for HEAD using git describe
	like "git gcc-descr" does.  Drop "revision" from gcc/REVISION.
---
 contrib/gcc_update | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

Comments

Richard Biener July 19, 2021, 10:39 a.m. UTC | #1
On Fri, Jul 16, 2021 at 12:37 PM Serge Belyshev
<belyshev@depni.sinp.msu.ru> wrote:
>
> Based on discussion I've chosen open-coded version without commit hash.

As said I'd prefer one with (shortened) hash, but then I'm not angry
if people agree on sth else.

> >> > > ...  Perhaps rename the r, o, rr and m temporaries.
>
> I like it better with short names, there is no other code in that
> script to clash with.  (Also, two adjacent case branches for hg and svn
> are essentialy dead now).
>
> >> ...  Perhaps also replace both HEAD occurences with $revision
>
> not sure about that: should not they be exactly equivalent in all cases?
>
> ---
> gcc_update: use human readable name for revision string in gcc/REVISION
>
> contrib/Changelog:
>
>         * gcc_update: derive human readable name for HEAD using git describe
>         like "git gcc-descr" does.  Drop "revision" from gcc/REVISION.
> ---
>  contrib/gcc_update | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/gcc_update b/contrib/gcc_update
> index 80fac9fc995..558926b3a2d 100755
> --- a/contrib/gcc_update
> +++ b/contrib/gcc_update
> @@ -332,7 +332,22 @@ case $vcs_type in
>              exit 1
>         fi
>
> -       revision=`$GCC_GIT log -n1 --pretty=tformat:%p:%t:%H`
> +       # Open-coded version of "git gcc-descr" from contrib/gcc-git-customization.sh
> +       revision=`$GCC_GIT log -n1 --pretty=tformat:%h`
> +       r=`$GCC_GIT describe --all --match 'basepoints/gcc-[0-9]*' HEAD \
> +          | 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'`;
> +       if test -n $r; then
> +               o=`$GCC_GIT config --get gcc-config.upstream`;
> +               rr=`echo $r | sed -n 's,^r\([0-9]\+\)-[0-9]\+\(-g[0-9a-f]\+\)\?$,\1,p'`;
> +               if $GCC_GIT rev-parse --verify --quiet ${o:-origin}/releases/gcc-$rr >/dev/null; then
> +                       m=releases/gcc-$rr;
> +               else
> +                       m=master;
> +               fi;
> +               if $GCC_GIT merge-base --is-ancestor HEAD ${o:-origin}/$m; then
> +                       revision=$r;
> +               fi
> +       fi
>         branch=`$GCC_GIT name-rev --name-only HEAD || :`
>         ;;
>
> @@ -414,6 +429,6 @@ rm -f LAST_UPDATED gcc/REVISION
>      date
>      echo "`TZ=UTC date` (revision $revision)"
>  } > LAST_UPDATED
> -echo "[$branch revision $revision]" > gcc/REVISION
> +echo "[$branch $revision]" > gcc/REVISION
>
>  touch_files_reexec
Iain Sandoe July 19, 2021, 10:47 a.m. UTC | #2
> On 19 Jul 2021, at 11:39, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> On Fri, Jul 16, 2021 at 12:37 PM Serge Belyshev
> <belyshev@depni.sinp.msu.ru> wrote:
>> 
>> Based on discussion I've chosen open-coded version without commit hash.
> 
> As said I'd prefer one with (shortened) hash,

Likewise, I’ve been using a local change to produce “r12-2447-gcca1e30db142”  since soon after
change; I suspect that 12 digits is ‘enough’.  It makes it easier for the folks who want to find by 
SHA1 as well as folks who want to find by revision number.

> but then I'm not angry
> if people agree on sth else.

also likewise…

> 
>>>>>> ...  Perhaps rename the r, o, rr and m temporaries.
>> 
>> I like it better with short names, there is no other code in that
>> script to clash with.  (Also, two adjacent case branches for hg and svn
>> are essentialy dead now).
>> 
>>>> ...  Perhaps also replace both HEAD occurences with $revision
>> 
>> not sure about that: should not they be exactly equivalent in all cases?
>> 
>> ---
>> gcc_update: use human readable name for revision string in gcc/REVISION
>> 
>> contrib/Changelog:
>> 
>>        * gcc_update: derive human readable name for HEAD using git describe
>>        like "git gcc-descr" does.  Drop "revision" from gcc/REVISION.
>> ---
>> contrib/gcc_update | 19 +++++++++++++++++--
>> 1 file changed, 17 insertions(+), 2 deletions(-)
>> 
>> diff --git a/contrib/gcc_update b/contrib/gcc_update
>> index 80fac9fc995..558926b3a2d 100755
>> --- a/contrib/gcc_update
>> +++ b/contrib/gcc_update
>> @@ -332,7 +332,22 @@ case $vcs_type in
>>             exit 1
>>        fi
>> 
>> -       revision=`$GCC_GIT log -n1 --pretty=tformat:%p:%t:%H`
>> +       # Open-coded version of "git gcc-descr" from contrib/gcc-git-customization.sh
>> +       revision=`$GCC_GIT log -n1 --pretty=tformat:%h`
>> +       r=`$GCC_GIT describe --all --match 'basepoints/gcc-[0-9]*' HEAD \
>> +          | 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'`;
>> +       if test -n $r; then
>> +               o=`$GCC_GIT config --get gcc-config.upstream`;
>> +               rr=`echo $r | sed -n 's,^r\([0-9]\+\)-[0-9]\+\(-g[0-9a-f]\+\)\?$,\1,p'`;
>> +               if $GCC_GIT rev-parse --verify --quiet ${o:-origin}/releases/gcc-$rr >/dev/null; then
>> +                       m=releases/gcc-$rr;
>> +               else
>> +                       m=master;
>> +               fi;
>> +               if $GCC_GIT merge-base --is-ancestor HEAD ${o:-origin}/$m; then
>> +                       revision=$r;
>> +               fi
>> +       fi
>>        branch=`$GCC_GIT name-rev --name-only HEAD || :`
>>        ;;
>> 
>> @@ -414,6 +429,6 @@ rm -f LAST_UPDATED gcc/REVISION
>>     date
>>     echo "`TZ=UTC date` (revision $revision)"
>> } > LAST_UPDATED
>> -echo "[$branch revision $revision]" > gcc/REVISION
>> +echo "[$branch $revision]" > gcc/REVISION
>> 
>> touch_files_reexec
Jakub Jelinek July 19, 2021, 11:09 a.m. UTC | #3
On Mon, Jul 19, 2021 at 11:47:01AM +0100, Iain Sandoe wrote:
> 
> 
> > On 19 Jul 2021, at 11:39, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > 
> > On Fri, Jul 16, 2021 at 12:37 PM Serge Belyshev
> > <belyshev@depni.sinp.msu.ru> wrote:
> >> 
> >> Based on discussion I've chosen open-coded version without commit hash.
> > 
> > As said I'd prefer one with (shortened) hash,
> 
> Likewise, I’ve been using a local change to produce “r12-2447-gcca1e30db142”  since soon after
> change; I suspect that 12 digits is ‘enough’.  It makes it easier for the folks who want to find by 
> SHA1 as well as folks who want to find by revision number.

If the patch is changed from
	revision=$r;
to
	revision=${r}-g${revision};
then the exact hash length isn't hardcoded to 12 digits, but whatever git
chooses to make it unique (with the current state of repository).
Of course, changes later on in the repository can introduce collisions and
more hash letters might be needed, but that is a general git problem.  And
at least when we have the rXX-YYYY-gZZZZZZZZZ revisions, it is still unique
on the release branches, just one might need to use
$(git gcc-descr `echo $rev | sed 's/-g[0-9a-f]*$//'`)
instead of just
$rev
in case such collision happens if git tells rXX-YYYY-gZZZZZZZZ is ambiguous.

	Jakub
diff mbox series

Patch

diff --git a/contrib/gcc_update b/contrib/gcc_update
index 80fac9fc995..558926b3a2d 100755
--- a/contrib/gcc_update
+++ b/contrib/gcc_update
@@ -332,7 +332,22 @@  case $vcs_type in
             exit 1
 	fi
 
-	revision=`$GCC_GIT log -n1 --pretty=tformat:%p:%t:%H`
+	# Open-coded version of "git gcc-descr" from contrib/gcc-git-customization.sh
+	revision=`$GCC_GIT log -n1 --pretty=tformat:%h`
+	r=`$GCC_GIT describe --all --match 'basepoints/gcc-[0-9]*' HEAD \
+	   | 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'`;
+	if test -n $r; then
+		o=`$GCC_GIT config --get gcc-config.upstream`;
+		rr=`echo $r | sed -n 's,^r\([0-9]\+\)-[0-9]\+\(-g[0-9a-f]\+\)\?$,\1,p'`;
+		if $GCC_GIT rev-parse --verify --quiet ${o:-origin}/releases/gcc-$rr >/dev/null; then
+			m=releases/gcc-$rr;
+		else
+			m=master;
+		fi;
+		if $GCC_GIT merge-base --is-ancestor HEAD ${o:-origin}/$m; then
+			revision=$r;
+		fi
+	fi
 	branch=`$GCC_GIT name-rev --name-only HEAD || :`
 	;;    
 
@@ -414,6 +429,6 @@  rm -f LAST_UPDATED gcc/REVISION
     date
     echo "`TZ=UTC date` (revision $revision)"
 } > LAST_UPDATED
-echo "[$branch revision $revision]" > gcc/REVISION
+echo "[$branch $revision]" > gcc/REVISION
 
 touch_files_reexec