 
   @add: (filepath, callback) ->
     @process({
-      command: @_gitCommand(),
+      command: GitCmd,
       args: ['add', filepath],
       options: { cwd: @_repoWorkDir() },
       stdout: (line) -> console.log line

class GitNotFoundError extends Error

  constructor: (message) ->
    super(message)

class GitBridge



  constructor: ->

  @locateGitAnd: (callback) ->
    # Use an explicitly provided path if one is available.
    possiblePath = atom.config.get 'merge-conflicts.gitPath'
    if possiblePath
      GitCmd = possiblePath
      callback(null)
      return

    search = [
      'git' # Search the inherited execution PATH. Unreliable on Macs.
      '/usr/local/bin/git' # Homebrew
      'C:\\Program Files (x86)\\Git\\bin\\git' # Reasonable Windows default
    ]

    possiblePath = search.shift()

    exitHandler = (code) =>
      if code is 0
        GitCmd = possiblePath
        callback(null)
        return

      possiblePath = search.shift()

      unless possiblePath?
        callback(new GitNotFoundError("Please set the 'Git Path' correctly in the Atom settings "
          "for the Merge Conflicts package."))
        return

      @process({
        command: possiblePath,
        args: ['--version'],
        exit: exitHandler
      })

    @process({
      command: possiblePath,
      args: ['--version'],
      exit: exitHandler
    })

  @_repoWorkDir: -> atom.project.getRepo()?.getWorkingDirectory()

