From d13f01337cdd6302aa6c42feda99e0ec1fcdbeac Mon Sep 17 00:00:00 2001 From: joshaber Date: Tue, 16 Feb 2016 17:18:24 -0500 Subject: [PATCH 1/2] Don't remove the index lock. --- lib/repository.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/repository.js b/lib/repository.js index 121543ebd..6fea2bd75 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -1409,12 +1409,7 @@ Repository.prototype.stageLines = }); }; - var indexLock = repo.path().replace(".git/", "") + ".git/index.lock"; - - return fse.remove(indexLock) - .then(function() { - return repo.openIndex(); - }) + return repo.openIndex() .then(function(indexResult) { index = indexResult; return index.read(1); From 0581567c4d721c80bb41000659a297b14fd03f25 Mon Sep 17 00:00:00 2001 From: joshaber Date: Tue, 16 Feb 2016 17:18:42 -0500 Subject: [PATCH 2/2] Calculate the diff after refreshing the index. --- lib/repository.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/repository.js b/lib/repository.js index 6fea2bd75..1da4e29f5 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -1361,20 +1361,22 @@ Repository.prototype.stageLines = var repo = this; var index; - var diffPromise = isSelectionStaged ? - repo.getHeadCommit() - .then(function getTreeFromCommit(commit) { - return commit.getTree(); - }) - .then(function getDiffFromTree(tree) { - return NodeGit.Diff.treeToIndex(repo, tree, index); - }) - : - NodeGit.Diff.indexToWorkdir(repo, index, { - flags: - NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | - NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS - }); + var diffPromise = function diffPromise() { + return isSelectionStaged ? + repo.getHeadCommit() + .then(function getTreeFromCommit(commit) { + return commit.getTree(); + }) + .then(function getDiffFromTree(tree) { + return NodeGit.Diff.treeToIndex(repo, tree, index); + }) + : + NodeGit.Diff.indexToWorkdir(repo, index, { + flags: + NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | + NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS + }); + }; //The following chain checks if there is a patch with no hunks left for the //file, and no filemode changes were done on the file. It is then safe to @@ -1415,7 +1417,7 @@ Repository.prototype.stageLines = return index.read(1); }) .then(function() { - return diffPromise; + return diffPromise(); }) .then(function(diff) { if (!(NodeGit.Status.file(repo, filePath) &