diff --git a/update_depot_tools b/update_depot_tools index 00859e338..f60d87e95 100755 --- a/update_depot_tools +++ b/update_depot_tools @@ -63,6 +63,26 @@ function test_git_svn { fi } +function is_git_clone_repo { + "$GIT" config remote.origin.fetch > /dev/null +} + +function update_git_repo { + if is_git_clone_repo; then + git fetch -q origin > /dev/null + git rebase -q origin > /dev/null + return 0 + fi + + test_git_svn + # work around a git-svn --quiet bug + OUTPUT=`"$GIT" svn rebase -q -q` + if [[ ! "$OUTPUT" == *Current.branch* ]]; then + echo $OUTPUT 1>&2 + fi + return 0 +} + # Get the current SVN revision. get_svn_revision() { LANGUAGE=C "$SVN" info "$base_dir" | \ @@ -73,12 +93,7 @@ get_svn_revision() { if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ] then cd $base_dir - test_git_svn - # work around a git-svn --quiet bug - OUTPUT=`"$GIT" svn rebase -q -q` - if [[ ! "$OUTPUT" == *Current.branch* ]]; then - echo $OUTPUT 1>&2 - fi + update_git_repo cd - > /dev/null fi diff --git a/update_depot_tools.bat b/update_depot_tools.bat index 990ea31ee..d44fba63f 100644 --- a/update_depot_tools.bat +++ b/update_depot_tools.bat @@ -13,6 +13,8 @@ setlocal :: not already in the PATH environment variable. call "%~dp0bootstrap\win\win_tools.bat" force if errorlevel 1 goto :EOF +:: Now clear errorlevel so it can be set by other programs later. +set errorlevel= :: Shall skip automatic update? IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF @@ -31,5 +33,13 @@ goto :EOF :GIT_UPDATE cd /d "%~dp0." +call git config remote.origin.fetch > NUL +if errorlevel 1 goto :GIT_SVN_UPDATE +call git fetch -q origin > NUL +call git rebase -q origin > NUL +goto :EOF + +:GIT_SVN_UPDATE +cd /d "%~dp0." call git svn rebase -q -q goto :EOF