diff --git a/src/git.coffee b/src/git.coffee index f2888eb28..c4dfe6613 100644 --- a/src/git.coffee +++ b/src/git.coffee @@ -1,9 +1,12 @@ +{join} = require 'path' + _ = require 'underscore-plus' -fs = require 'fs-plus' -Task = require './task' {Emitter, Subscriber} = require 'emissary' +fs = require 'fs-plus' GitUtils = require 'git-utils' +Task = require './task' + # Public: Represents the underlying git operations performed by Atom. # # This class shouldn't be instantiated directly but instead by accessing the @@ -125,13 +128,14 @@ class Git # Returns a {Number} representing the status. This value can be passed to # {::isStatusModified} or {::isStatusNew} to get more information. getPathStatus: (path) -> - currentPathStatus = @statuses[path] ? 0 repo = @getRepo(path) + relativePath = @relativize(path) + currentPathStatus = @statuses[relativePath] ? 0 pathStatus = repo.getStatus(repo.relativize(path)) ? 0 if pathStatus > 0 - @statuses[path] = pathStatus + @statuses[relativePath] = pathStatus else - delete @statuses[path] + delete @statuses[relativePath] if currentPathStatus isnt pathStatus @emit 'status-changed', path, pathStatus pathStatus @@ -322,6 +326,14 @@ class Git getCachedUpstreamAheadBehindCount: (path) -> @getRepo(path).upstream ? @upstream + # Public: Get the cached status for the given path. + # + # path - A {String} path in the repository, relative or absolute. + # + # Returns a status {Number} or null if path is not in the cache. + getCachedPathStatus: (path) -> + @statuses[@relativize(path)] + # Public: Returns true if the given branch exists. hasBranch: (branch) -> @getReferenceTarget("refs/heads/#{branch}")? diff --git a/src/repository-status-handler.coffee b/src/repository-status-handler.coffee index 205fae0d3..059a21fbd 100644 --- a/src/repository-status-handler.coffee +++ b/src/repository-status-handler.coffee @@ -13,7 +13,7 @@ module.exports = (repoPath) -> # Statuses in main repo workingDirectoryPath = repo.getWorkingDirectory() for filePath, status of repo.getStatus() - statuses[path.join(workingDirectoryPath, filePath)] = status + statuses[filePath] = status # Statuses in submodules for submodulePath, submoduleRepo of repo.submodules @@ -23,7 +23,7 @@ module.exports = (repoPath) -> workingDirectoryPath = submoduleRepo.getWorkingDirectory() for filePath, status of submoduleRepo.getStatus() - statuses[path.join(workingDirectoryPath, filePath)] = status + statuses[repo.relativize(path.join(workingDirectoryPath, filePath))] = status upstream = repo.getAheadBehindCount() branch = repo.getHead()