summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-01-27 16:01:55 +0100
committerMartin Liska <mliska@suse.cz>2022-01-27 18:44:47 +0100
commit9cbfbe2497c0117b0598e35658248bc723c0b931 (patch)
tree2b369a3f9b166db5aa95ea2a9aa4c35fa47dde7e /contrib
parentdec8d0e5fa00ceb2ded78b8a3eba8976d860a90e (diff)
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. * gcc-git-customization.sh: Use the created files. Co-Authored-By: Martin Jambor <mjambor@suse.cz>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/gcc-git-customization.sh4
-rwxr-xr-xcontrib/git-descr.sh37
-rwxr-xr-xcontrib/git-undescr.sh13
3 files changed, 52 insertions, 2 deletions
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..eb258148a66
--- /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=no
+ ;;
+ --long|--full) long=yes short=no
+ ;;
+ *) 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);