summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Vigerlöf <magnus.vigerlof@gmail.com>2011-06-07 22:17:34 +0200
committerMagnus Vigerlöf <magnus.vigerlof@gmail.com>2011-06-07 22:17:34 +0200
commitf86b2141843e3dced579330dd8e11c5ea01f9dd4 (patch)
tree0a581db740f915e4c60d8b29a75f6ffa7856bc87
parent045b76c6d63c091bdd43235cb035a61501421529 (diff)
Replace the shell code that tries to emulate git config with an error.
Replace the code with an error message that git has to be in the PATH instead of trying to parse gerrit.conf with shell code. The shell code do not remove whitespaces as it should and this will give stranger errors when looking for java later in the script (all platforms/shells). This code doesn't seem to have been used anyway. Change-Id: Ideba5b950a97c0e77839cbddd4616ef737470da2
-rwxr-xr-xgerrit-pgm/src/main/resources/com/google/gerrit/pgm/gerrit.sh84
1 files changed, 23 insertions, 61 deletions
diff --git a/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/gerrit.sh b/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/gerrit.sh
index 9aba73e7f6..4538bce9d5 100755
--- a/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/gerrit.sh
+++ b/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/gerrit.sh
@@ -54,70 +54,22 @@ running() {
get_config() {
if test -f "$GERRIT_CONFIG" ; then
- if type git >/dev/null 2>&1 ; then
- if test "x$1" = x--int ; then
- # Git might not be able to expand "8g" properly. If it gives
- # us 0 back retry for the raw string and expand ourselves.
- #
- n=`git config --file "$GERRIT_CONFIG" --int "$2"`
- if test x0 = "x$n" ; then
- n=`git config --file "$GERRIT_CONFIG" --get "$2"`
- case "$n" in
- *g) n=`expr ${n%%g} \* 1024`m ;;
- *k) n=`expr ${n%%k} \* 1024` ;;
- *) : ;;
- esac
- fi
- echo "$n"
- else
- git config --file "$GERRIT_CONFIG" $1 "$2"
- fi
-
- else
- # This is a very crude parser for the git configuration file.
- # Its not perfect but it can at least pull some basic values
- # from a reasonably standard format.
+ if test "x$1" = x--int ; then
+ # Git might not be able to expand "8g" properly. If it gives
+ # us 0 back retry for the raw string and expand ourselves.
#
- s=`echo "$2" | cut -d. -f1`
- k=`echo "$2" | cut -d. -f2`
- i=0
- while read n ; do
+ n=`git config --file "$GERRIT_CONFIG" --int "$2"`
+ if test x0 = "x$n" ; then
+ n=`git config --file "$GERRIT_CONFIG" --get "$2"`
case "$n" in
- '['$s']') i=1 ;;
- '['*']' ) i=0 ;;
+ *g) n=`expr ${n%%g} \* 1024`m ;;
+ *k) n=`expr ${n%%k} \* 1024` ;;
+ *) : ;;
esac
- test $i || continue
-
- case "$n" in
- *[' ']$k[' ']*=*) : ;;
- [' ']$k=*) : ;;
- $k[' ']*=*) : ;;
- $k=*) : ;;
- *) continue ;;
- esac
-
- n=${n#*=}
-
- if test "x$1" = x--bool ; then
- case "$n" in
- true|on|1|yes) n=true ;;
- false|off|0|no) n=false ;;
- *)
- echo >&2 "error: $2=$n not supported, assuming false."
- n=false
- ;;
- esac
- fi
-
- if test "x$1" = x--int ; then
- case "$n" in
- *g) n=`expr ${n%%g} \* 1024`m ;;
- *k) n=`expr ${n%%k} \* 1024` ;;
- *) : ;;
- esac
- fi
- echo "$n"
- done <"$GERRIT_CONFIG"
+ fi
+ echo "$n"
+ else
+ git config --file "$GERRIT_CONFIG" $1 "$2"
fi
fi
}
@@ -174,6 +126,16 @@ TMPJ=$TMP/j$$
GERRIT_INSTALL_TRACE_FILE=etc/gerrit.config
##################################################
+# No git in PATH? Needed for gerrit.confg parsing
+##################################################
+if type git >/dev/null 2>&1 ; then
+ : OK
+else
+ echo >&2 "** ERROR: Cannot find git in PATH"
+ exit 1
+fi
+
+##################################################
# Try to determine GERRIT_SITE if not set
##################################################
if test -z "$GERRIT_SITE" ; then