From 1047ca509a63cc229494f17cffb92bd0ead3c79e Mon Sep 17 00:00:00 2001 From: luca020400 Date: Thu, 5 May 2016 21:53:40 +0200 Subject: [PATCH] envsetup: Fix aosp & caf remote Fixes: sed: -e expression #1, char 9: unknown option to `s' * Return if .git directory is missing and move it on the top * Update cmremote strings ( match caf/aosp remote ) Change-Id: Ifb606a20f308e7317e9ce519d682a3fdb8bfe9bf --- envsetup.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/envsetup.sh b/envsetup.sh index 361d98d3122..ab6cb26df85 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -1685,13 +1685,13 @@ function godir () { function cmremote() { - git remote rm cmremote 2> /dev/null - GERRIT_REMOTE=$(git config --get remote.github.projectname) - if [ -z "$GERRIT_REMOTE" ] + if ! git rev-parse --git-dir &> /dev/null then - echo Unable to set up the git remote, are you under a git repo? - return 0 + echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up." + return 1 fi + git remote rm cmremote 2> /dev/null + GERRIT_REMOTE=$(git config --get remote.github.projectname) CMUSER=$(git config --get review.review.cyanogenmod.org.username) if [ -z "$CMUSER" ] then @@ -1699,17 +1699,18 @@ function cmremote() else git remote add cmremote ssh://$CMUSER@review.cyanogenmod.org:29418/$GERRIT_REMOTE fi - echo You can now push to "cmremote". + echo "Remote 'cmremote' created" } function aospremote() { - git remote rm aosp 2> /dev/null - if [ ! -d .git ] + if ! git rev-parse --git-dir &> /dev/null then - echo .git directory not found. Please run this from the root directory of the Android repository you wish to set up. + echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up." + return 1 fi - PROJECT=`pwd -P | sed s#$ANDROID_BUILD_TOP/##g` + git remote rm aosp 2> /dev/null + PROJECT=${$(pwd -P)#$ANDROID_BUILD_TOP/} if (echo $PROJECT | grep -qv "^device") then PFX="platform/" @@ -1720,12 +1721,13 @@ function aospremote() function cafremote() { - git remote rm caf 2> /dev/null - if [ ! -d .git ] + if ! git rev-parse --git-dir &> /dev/null then - echo .git directory not found. Please run this from the root directory of the Android repository you wish to set up. + echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up." + return 1 fi - PROJECT=`pwd -P | sed s#$ANDROID_BUILD_TOP/##g` + git remote rm caf 2> /dev/null + PROJECT=${$(pwd -P)#$ANDROID_BUILD_TOP/} if (echo $PROJECT | grep -qv "^device") then PFX="platform/"