Avoid Coordinate copies in DelaunayTriangulationBuilder::envelope
[geos.git] / tools / svn_repo_revision.sh
blobe1971eb98e55020bef8c894c506a82bee5450ce6
1 #!/bin/sh
3 LC_ALL="C" # what for ?
5 [ -z "$top_srcdir" ] && top_srcdir="."
6 rev_file=$top_srcdir'/geos_svn_revision.h'
8 read_rev() {
10 if test -d $top_srcdir"/.svn"; then
11 read_rev_svn
12 elif test -d $top_srcdir"/.git"; then
13 read_rev_git
14 else
15 echo "Can't fetch local revision (neither .svn nor .git found)" >&2
16 echo 0
20 read_rev_git() {
22 # TODO: test on old systems, I think I saw some `which`
23 # implementations returning "nothing found" or something
24 # like that, making the later if ( ! $svn_exe ) always false
26 git_exe=`which git`;
27 if test -z "$git_exe"; then
28 echo "Can't fetch SVN revision: no git executable found" >&2
29 echo 0;
32 rev=`${git_exe} log --grep=git-svn -1 | grep git-svn | cut -d@ -f2 | cut -d' ' -f1`
34 if test -z "$rev"; then
35 echo "Can't fetch SVN revision from git log" >&2
36 echo 0
37 else
38 echo $rev
42 read_rev_svn() {
44 # TODO: test on old systems, I think I saw some `which`
45 # implementations returning "nothing found" or something
46 # like that, making the later if ( ! $svn_exe ) always false
48 svn_exe=`which svn`
49 if test -z "$svn_exe"; then
50 echo "Can't fetch SVN revision: no svn executable found" >&2
51 echo 0;
54 svn_info=`"${svn_exe}" info | grep 'Last Changed Rev:' | cut -d: -f2`
56 if test -z "$svn_info"; then
57 echo "Can't fetch SVN revision with `svn info`" >&2
58 echo 0
59 else
60 echo ${svn_info}
64 write_defn() {
65 rev=$1
66 oldrev=0
68 # Do not override the file if new detected
69 # revision isn't zero nor different from the existing one
70 if test -f $rev_file; then
71 oldrev=`grep GEOS_SVN_REVISION ${rev_file} | awk '{print $2}'`
72 if test "$rev" = 0 -o "$rev" = "$oldrev"; then
73 echo "Not updating existing rev file at $oldrev" >&2
74 return;
78 echo "#define GEOS_SVN_REVISION $rev" | tee $rev_file
79 echo "Wrote rev '$rev' in file '$rev_file'" >&2
82 # Read the svn revision number
83 svn_rev=`read_rev`
85 # Write it
86 write_defn $svn_rev