Make path references OS independent

Change-Id: I5573995adfd52fd54bddc62d1d1ea78fb1328130
diff --git a/command.py b/command.py
index 6e4e2c5..4e0253f 100644
--- a/command.py
+++ b/command.py
@@ -90,7 +90,7 @@
         project = all.get(arg)
 
         if not project:
-          path = os.path.abspath(arg)
+          path = os.path.abspath(arg).replace('\\', '/')
 
           if not by_path:
             by_path = dict()
@@ -100,13 +100,15 @@
           try:
             project = by_path[path]
           except KeyError:
+            oldpath = None
             while path \
-              and path != '/' \
+              and path != oldpath \
               and path != self.manifest.topdir:
               try:
                 project = by_path[path]
                 break
               except KeyError:
+                oldpath = path
                 path = os.path.dirname(path)
 
         if not project:
diff --git a/manifest_xml.py b/manifest_xml.py
index d888653..35318d0 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -357,7 +357,7 @@
       worktree = None
       gitdir = os.path.join(self.topdir, '%s.git' % name)
     else:
-      worktree = os.path.join(self.topdir, path)
+      worktree = os.path.join(self.topdir, path).replace('\\', '/')
       gitdir = os.path.join(self.repodir, 'projects/%s.git' % path)
 
     project = Project(manifest = self,
diff --git a/project.py b/project.py
index 5a143a7..1cea959 100644
--- a/project.py
+++ b/project.py
@@ -233,8 +233,8 @@
     self.manifest = manifest
     self.name = name
     self.remote = remote
-    self.gitdir = gitdir
-    self.worktree = worktree
+    self.gitdir = gitdir.replace('\\', '/')
+    self.worktree = worktree.replace('\\', '/')
     self.relpath = relpath
     self.revisionExpr = revisionExpr
 
diff --git a/repo b/repo
index ff7c418..3a545cc 100755
--- a/repo
+++ b/repo
@@ -432,10 +432,14 @@
   dir = os.getcwd()
   repo = None
 
-  while dir != '/' and not repo:
+  olddir = None
+  while dir != '/' \
+    and dir != olddir \
+    and not repo:
     repo = os.path.join(dir, repodir, REPO_MAIN)
     if not os.path.isfile(repo):
       repo = None
+      olddir = dir
       dir = os.path.dirname(dir)
   return (repo, os.path.join(dir, repodir))