diff --git a/spec/git-repository-spec.coffee b/spec/git-repository-spec.coffee index ef87d83ee..d427fc3b9 100644 --- a/spec/git-repository-spec.coffee +++ b/spec/git-repository-spec.coffee @@ -199,7 +199,7 @@ describe "GitRepository", -> beforeEach -> workingDirectory = copyRepository() - repo = new GitRepository(workingDirectory) + repo = new GitRepository(workingDirectory, {project: atom.project, config: atom.config}) modifiedPath = path.join(workingDirectory, 'file.txt') newPath = path.join(workingDirectory, 'untracked.txt') cleanPath = path.join(workingDirectory, 'other.txt') @@ -249,6 +249,22 @@ describe "GitRepository", -> expect(repo.isStatusModified(status)).toBe false expect(repo.isStatusNew(status)).toBe false + it "works correctly when the project has multiple folders (regression)", -> + atom.project.addPath(workingDirectory) + atom.project.addPath(path.join(__dirname, 'fixtures', 'dir')) + statusHandler = jasmine.createSpy('statusHandler') + repo.onDidChangeStatuses statusHandler + + repo.refreshStatus() + + waitsFor -> + statusHandler.callCount > 0 + + runs -> + expect(repo.getCachedPathStatus(cleanPath)).toBeUndefined() + expect(repo.isStatusNew(repo.getCachedPathStatus(newPath))).toBeTruthy() + expect(repo.isStatusModified(repo.getCachedPathStatus(modifiedPath))).toBeTruthy() + it 'caches statuses that were looked up synchronously', -> originalContent = 'undefined' fs.writeFileSync(modifiedPath, 'making this path modified') diff --git a/src/git-repository.coffee b/src/git-repository.coffee index 85600bba7..c59615378 100644 --- a/src/git-repository.coffee +++ b/src/git-repository.coffee @@ -3,6 +3,7 @@ _ = require 'underscore-plus' {Emitter, Disposable, CompositeDisposable} = require 'event-kit' fs = require 'fs-plus' +path = require 'path' GitUtils = require 'git-utils' Task = require './task' @@ -468,8 +469,8 @@ class GitRepository @handlerPath ?= require.resolve('./repository-status-handler') relativeProjectPaths = @project?.getPaths() - .map (path) => @relativize(path) - .filter (path) -> path.length > 0 + .map (projectPath) => @relativize(projectPath) + .filter (projectPath) -> projectPath.length > 0 and not path.isAbsolute(projectPath) @statusTask?.terminate() new Promise (resolve) =>