How do I remove-and-commit + fs.unlink(... and have git know that everything is up to date / commited?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.8k
- Forks
- 704
- PR merge metrics
- No merged PRs in 30d
Description
If I create new files in my repo and use .addAll(file_paths), commit and then run git-cola in the directory I get 0 reports on files being in the directory which haven't been added to the repo.
The same thing happens when I use .removeAll(file_paths) but that only removes it from the index, not the actual files like git rm file.txt does, so I experimented with doing fs.unlink(... before and after doing removeAll but it always results in git-cola reporting modified files.
That is:
git init
touch test.txt
git add test.txt
git commit -m "test"
git rm test.txt
git commit -m "rm test"
git-cola
Will show 0 reports on changes needing to be committed but my nodejs equivilant does show changes needing to be commited, why is that and what can I do about it?
- nodegit@0.7
My nodegit removeAll code:
...
function removeAndCommitFiles(root, file_paths, message) {
var dotgit = path.join(root, ".git");
var repository;
var index;
var oid;
nodegit.Repository.open(dotgit)
.then(function(repo) {
repository = repo;
return fs.ensureDir(repository.workdir());
})
.then(function() {
return repository.openIndex();
})
.then(function(indexResult) {
index = indexResult;
return index.read(1);
})
.then(function() {
return index.removeAll(file_paths);
})
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
})
.then(function(oidResult) {
oid = oidResult;
return nodegit.Reference.nameToId(repository, "HEAD");
})
.then(function(head) {
return repository.getCommit(head);
})
.then(function(parent) {
return repository.createCommit("HEAD", author, committer, message, oid, [parent]);
})
.done(function(commitId) {
// ...
});
}
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the removeAll, index.write, index.writeTree, and createCommit calls in the provided NodeGit example, then compare their repository state with the git rm and git-cola command-line sequence. Reproduce the mismatch and determine what repository state git-cola observes; done means the equivalent removal and commit report no pending changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, javascript, nodejs
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100