c-family: -Waddress-of-packed-member and casts
[official-gcc.git] / contrib / git-descr.sh
blob28db83abc08c0ba893e2a94d5afa3552fbeafb9e
1 #!/bin/sh
3 # Script to describe a GCC revision based on git hash
5 short=no
6 long=no
7 c=HEAD
9 for arg in "$@"
11 case "$arg" in
12 --short) short=yes long=no
14 --long|--full) long=yes short=no
16 *) c=$arg
17 esac
18 done
20 if test x$short = xyes; then
21 r=$(git describe --all --match 'basepoints/gcc-[0-9]*' $c | sed -n 's,^tags/,,;s,^basepoints/gcc-\([0-9][0-9]*\)-\([0-9][0-9]*\)-g[0-9a-f]*$,r\1-\2,p;s,^basepoints/gcc-\([0-9][0-9]*\)$,r\1-0,p');
22 elif test x$long = xyes; then
23 r=$(git describe --all --abbrev=40 --match 'basepoints/gcc-[0-9]*' $c | sed -n 's,^tags/,,;s,^basepoints/gcc-,r,p')
24 else
25 r=$(git describe --all --abbrev=14 --match 'basepoints/gcc-[0-9]*' $c | sed -n 's,^tags/,,;s,^basepoints/gcc-,r,p')
26 expr ${r:-no} : 'r[0-9]\+$' >/dev/null && r=${r}-0-g$(git rev-parse $c);
27 fi;
28 if test -n $r; then
29 o=$(git config --get gcc-config.upstream);
30 rr=$(echo $r | sed -n 's,^r\([0-9]\+\)-[0-9]\+\(-g[0-9a-f]\+\)\?$,\1,p');
31 if git rev-parse --verify --quiet ${o:-origin}/releases/gcc-$rr >/dev/null; then
32 m=releases/gcc-$rr;
33 else
34 m=master;
35 fi;
36 git merge-base --is-ancestor $c ${o:-origin}/$m && echo ${r};
37 fi;