Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions 39 lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1409,18 +1411,13 @@ Repository.prototype.stageLines =
});
};

var indexLock = repo.path().replace(".git/", "") + ".git/index.lock";

return fse.remove(indexLock)
.then(function() {
return repo.openIndex();
})
return repo.openIndex()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.then(function(indexResult) {
index = indexResult;
return index.read(1);
})
.then(function() {
return diffPromise;
return diffPromise();
})
.then(function(diff) {
if (!(NodeGit.Status.file(repo, filePath) &
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.