mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge pull request #11295 from atom/fix-submodule-line-diffs
Take the submodule into account in more instances.
This commit is contained in:
@@ -43,7 +43,6 @@ export default class GitRepositoryAsync {
|
||||
this.emitter = new Emitter()
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
this.pathStatusCache = {}
|
||||
this.workdir = null
|
||||
this.path = null
|
||||
|
||||
// NB: These needs to happen before the following .openRepository call.
|
||||
@@ -155,13 +154,13 @@ export default class GitRepositoryAsync {
|
||||
|
||||
// Public: Returns a {Promise} which resolves to the {String} working
|
||||
// directory path of the repository.
|
||||
getWorkingDirectory () {
|
||||
return this.getRepo().then(repo => {
|
||||
if (!this.workdir) {
|
||||
this.workdir = repo.workdir()
|
||||
getWorkingDirectory (_path) {
|
||||
return this.getRepo(_path).then(repo => {
|
||||
if (!repo.cachedWorkdir) {
|
||||
repo.cachedWorkdir = repo.workdir()
|
||||
}
|
||||
|
||||
return this.workdir
|
||||
return repo.cachedWorkdir
|
||||
})
|
||||
}
|
||||
|
||||
@@ -610,9 +609,9 @@ export default class GitRepositoryAsync {
|
||||
// * `added` The {Number} of added lines.
|
||||
// * `deleted` The {Number} of deleted lines.
|
||||
getDiffStats (_path) {
|
||||
return this.getRepo()
|
||||
return this.getRepo(_path)
|
||||
.then(repo => Promise.all([repo, repo.getHeadCommit()]))
|
||||
.then(([repo, headCommit]) => Promise.all([repo, headCommit.getTree(), this.getWorkingDirectory()]))
|
||||
.then(([repo, headCommit]) => Promise.all([repo, headCommit.getTree(), this.getWorkingDirectory(_path)]))
|
||||
.then(([repo, tree, wd]) => {
|
||||
const options = new Git.DiffOptions()
|
||||
options.contextLines = 0
|
||||
@@ -654,7 +653,7 @@ export default class GitRepositoryAsync {
|
||||
// * `newLines` The {Number} of lines in the new hunk
|
||||
getLineDiffs (_path, text) {
|
||||
let relativePath = null
|
||||
return Promise.all([this.getRepo(), this.getWorkingDirectory()])
|
||||
return Promise.all([this.getRepo(_path), this.getWorkingDirectory(_path)])
|
||||
.then(([repo, wd]) => {
|
||||
relativePath = this.relativize(_path, wd)
|
||||
return repo.getHeadCommit()
|
||||
@@ -692,7 +691,7 @@ export default class GitRepositoryAsync {
|
||||
// Returns a {Promise} that resolves or rejects depending on whether the
|
||||
// method was successful.
|
||||
checkoutHead (_path) {
|
||||
return Promise.all([this.getRepo(), this.getWorkingDirectory()])
|
||||
return Promise.all([this.getRepo(_path), this.getWorkingDirectory(_path)])
|
||||
.then(([repo, wd]) => {
|
||||
const checkoutOptions = new Git.CheckoutOptions()
|
||||
checkoutOptions.paths = [this.relativize(_path, wd)]
|
||||
|
||||
Reference in New Issue
Block a user