       git.decrementTaskCounter()
 
   checkoutBranch: ->
-    @branch_list.checkout_branch
+    @branchList.checkout_branch
 
   stash: ->
     git.git 'stash'

_ = require 'lodash'
fs = require 'fs'
path = require 'path'
{Model} = require 'backbone'

{git} = require '../git'
{FileList} = require './files'
{CurrentBranch, BranchList} = require './branches'
{CommitList} = require './commits'

module.exports =
class Repo extends Model
  initialize: (opts) ->
    @file_list = new FileList []
    @branch_list = new BranchList []
    @commit_list = new CommitList []
    @current_branch = new CurrentBranch(@headRefsCount() > 0)
    git.on 'reload', @reload

  reload: =>
    git.setPath()
    @file_list.reload()
    if @headRefsCount() > 0
      @current_branch.reload()
      @branch_list.reload()
      @commit_list.reload(@current_branch)

  selection: ->
    @active_list.selection()

  leaf: ->
    @active_list.leaf()

  commitMessagePath: ->
    path.join(
      atom.project.getRepo()?.getWorkingDirectory(),

        git.createBranch name, ->
          git.git "checkout #{name}"

  # Public: Initiate a user defined git command.
  initiateGitCommand: ->
    @trigger 'need_input',
      query: 'Git command'
      callback: (command) -> git.cmd command

  # Public: Push the repository to the remote.
  push: ->
    @currentBranch.push()

# Exports {Repo}.
module.exports = Repo
