From e19db6a2f7aa20b708ffa112767efbd378c94416 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 13 Jan 2020 15:15:17 +0100 Subject: [PATCH] contrib: Add git gcc-descr and gcc-undescr aliases. 2020-01-13 Jakub Jelinek * contrib/gcc-git-customization.sh: Add git gcc-descr and gcc-undescr aliases. --- contrib/ChangeLog | 5 +++++ contrib/gcc-git-customization.sh | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/contrib/ChangeLog b/contrib/ChangeLog index ddaff4fc6d8..dd0c4c4d8dd 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,8 @@ +2020-01-13 Jakub Jelinek + + * contrib/gcc-git-customization.sh: Add git gcc-descr and gcc-undescr + aliases. + 2010-01-13 Richard Earnshaw * gcc-git-customization.sh: New file. diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index 169c3a4d356..3b9d79d3d38 100755 --- a/contrib/gcc-git-customization.sh +++ b/contrib/gcc-git-customization.sh @@ -20,6 +20,11 @@ ask () { # Add a git command to find the git commit equivalent to legacy SVN revision NNN git config alias.svn-rev '!f() { rev=$1; shift; git log --all --grep="From-SVN: r\\?$rev\\b" "${@}"; } ; f' +# 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 r=\$(git describe --all --abbrev=40 --match 'basepoints/gcc-[0-9]*' \${2:-master} | 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}); test -n \$r && echo \${r}; else git describe --all --match 'basepoints/gcc-[0-9]*' \${1:-master} | sed -n 's,^tags/basepoints/gcc-\\([0-9]\\+\\)-\\([0-9]\\+\\)-g[0-9a-f]*\$,r\\1-\\2,p;s,^tags/basepoints/gcc-\\([0-9]\\+\\)\$,r\\1-0,p'; 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]*\$,\\1,p;s,^tags/basepoints/gcc-[0-9]\\+\$,0,p'); git rev-parse --verify \$h~\$(expr \$p - \$n); }; f" + # Make diff on MD files uses "(define" as a function marker. # Use this in conjunction with a .gitattributes file containing # *.md diff=md