Index: update_depot_tools |
diff --git a/update_depot_tools b/update_depot_tools |
index 00859e338be2dad2bc210cafc514a4613b78b71f..bf6d1c47b9f05c923ed4ed7f48c50f7317554bfa 100755 |
--- a/update_depot_tools |
+++ b/update_depot_tools |
@@ -63,6 +63,32 @@ function test_git_svn { |
fi |
} |
+function is_git_clone_repo { |
M-A Ruel
2012/04/30 14:17:34
Why isn't this sufficient? My bash-fu is lacking.
cmp
2012/04/30 18:12:37
That's a great suggestion. I didn't realize that
|
+ GITCONFIG="$("$GIT" config remote.origin.fetch > /dev/null)" |
+ GITCONFIG_RC="$?" |
+ if [ "$GITCONFIG_RC" == "0" ] |
+ then |
+ return 0 |
+ fi |
+ return 1 |
+} |
+ |
+function update_git_repo { |
+ if is_git_clone_repo; then |
+ git fetch -q origin |
+ git rebase -q origin |
+ 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 +99,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 |