Permalink
Browse files

Fix init for repos that don't have an origin/master

  • Loading branch information...
1 parent 44d04e0 commit e7a6e97c1803f8c11880c70ead036bc838c5ab6f @toddlipcon committed May 29, 2009
Showing with 10 additions and 1 deletion.
  1. +10 −1 crepo.py
View
@@ -37,8 +37,17 @@ def init(args):
logging.warn("Initializing project: %s" % name)
clone_remote = man.remotes[project.from_remote]
clone_url = clone_remote.fetch % name
- p = GitCommand(None, ["clone", clone_url, project.dir])
+ p = GitCommand(None, ["clone", "-o", project.from_remote, "-n", clone_url, project.dir])
p.Wait()
+ p = GitCommand(None, ["show-ref", "-q", "HEAD"], cwd=workdir_for_project(project))
+ if p.Wait():
+ # There is no HEAD (maybe origin/master doesnt exist) so check out the tracking
+ # branch
+ GitCommand(None, ["checkout", "--track", "-b", project.tracking_branch,
+ project.remote_refspec],
+ cwd=workdir_for_project(project)).Wait()
+ else:
+ GitCommand(None, ["checkout"], cwd=workdir_for_project(project)).Wait()
checkout_branches([])

0 comments on commit e7a6e97

Please sign in to comment.