   # Public: Returns true if at the root, false if in a subfolder of the
   # repository.
   isProjectAtRoot: ->
-    @projectAtRoot ?= atom.project.relativize(@getWorkingDirectory()) is ''
+    @projectAtRoot ?= @project?.relativize(@getWorkingDirectory()) is ''
 
   # Public: Makes a path relative to the repository's working directory.
   relativize: (path) -> @getRepo().relativize(path)

        @refreshIndex()
        @refreshStatus()

    if atom.project?
      @subscribe atom.project.buffers.onEach (buffer) => @subscribeToBuffer(buffer)

  # Private: Subscribes to buffer events.
  subscribeToBuffer: (buffer) ->


    @statuses = {}
    @upstream = {ahead: 0, behind: 0}
    {@project, refreshOnWindowFocus} = options

    refreshOnWindowFocus ?= true
    if refreshOnWindowFocus
