Skip to content

Commit 6ebc360

Browse files
committed
Merge pull request nodegit#986 from nodegit/add-refresh-index
Add `Repository#refreshIndex`
2 parents 5bd483b + 2a50623 commit 6ebc360

24 files changed

+148
-150
lines changed

examples/add-and-commit.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
3535
);
3636
})
3737
.then(function() {
38-
return repo.openIndex();
38+
return repo.refreshIndex();
3939
})
4040
.then(function(indexResult) {
4141
index = indexResult;
42-
return index.read(1);
4342
})
4443
.then(function() {
4544
// this file is in the root of the directory and doesn't need a full path

examples/create-new-repo.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ fse.ensureDir(path.resolve(__dirname, repoDir))
2020
return fse.writeFile(path.join(repository.workdir(), fileName), fileContent);
2121
})
2222
.then(function(){
23-
return repository.openIndex();
23+
return repository.refreshIndex();
2424
})
2525
.then(function(idx) {
2626
index = idx;
27-
return index.read(1);
2827
})
2928
.then(function() {
3029
return index.addByPath(fileName);

examples/details-for-tree-entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
1313

1414
// Tree entry doesn't have any data associated with the actual entry
1515
// To get that we need to get the index entry that this points to
16-
return repo.openIndex().then(function(index) {
16+
return repo.refreshIndex().then(function(index) {
1717
var indexEntry = index.getByPath(treeEntry.path());
1818

1919
// With the index entry we can now view the details for the tree entry

examples/general.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
319319

320320
// The [index file API][gi] allows you to read, traverse, update and write
321321
// the Git index file (sometimes thought of as the staging area).
322-
return repo.openIndex();
322+
return repo.refreshIndex();
323323
})
324324

325325
.then(function(index) {

examples/index-add-and-remove.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var fse = promisify(require("fs-extra"));
55

66
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
77
.then(function(repo) {
8-
return repo.openIndex()
8+
return repo.refreshIndex()
99
.then(function(index) {
1010
var fileContent = {
1111
newFile1: "this has some content",

examples/merge-cleanly.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ fse.remove(path.resolve(__dirname, repoDir))
4343

4444
// Load up the repository index and make our initial commit to HEAD
4545
.then(function() {
46-
return repository.openIndex();
46+
return repository.refreshIndex();
4747
})
4848
.then(function(index) {
49-
index.read(1);
5049
index.addByPath(ourFileName);
5150
index.write();
5251

@@ -79,10 +78,9 @@ fse.remove(path.resolve(__dirname, repoDir))
7978
);
8079
})
8180
.then(function() {
82-
return repository.openIndex();
81+
return repository.refreshIndex();
8382
})
8483
.then(function(index) {
85-
index.read(1);
8684
index.addByPath(theirFileName);
8785
index.write();
8886

examples/merge-with-conflicts.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ fse.remove(path.resolve(__dirname, repoDir))
4949

5050
// Load up the repository index and make our initial commit to HEAD
5151
.then(function() {
52-
return repository.openIndex();
52+
return repository.refreshIndex();
5353
})
5454
.then(function(index) {
55-
index.read(1);
5655
index.addByPath(fileName);
5756
index.write();
5857

@@ -94,9 +93,8 @@ fse.remove(path.resolve(__dirname, repoDir))
9493
);
9594
})
9695
.then(function() {
97-
return repository.openIndex()
96+
return repository.refreshIndex()
9897
.then(function(index) {
99-
index.read(1);
10098
index.addByPath(fileName);
10199
index.write();
102100

@@ -122,8 +120,7 @@ fse.remove(path.resolve(__dirname, repoDir))
122120
);
123121
})
124122
.then(function() {
125-
return repository.openIndex().then(function(index) {
126-
index.read(1);
123+
return repository.refreshIndex().then(function(index) {
127124
index.addByPath(fileName);
128125
index.write();
129126

@@ -173,9 +170,8 @@ fse.remove(path.resolve(__dirname, repoDir))
173170
// we need to get a new index as the other one isnt backed to
174171
// the repository in the usual fashion, and just behaves weirdly
175172
.then(function() {
176-
return repository.openIndex().then(function(index) {
173+
return repository.refreshIndex().then(function(index) {
177174

178-
index.read(1);
179175
index.addByPath(fileName);
180176
index.write();
181177

examples/push.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ fse.remove(path.resolve(__dirname, repoDir))
3030

3131
// Load up the repository index and make our initial commit to HEAD
3232
.then(function() {
33-
return repository.openIndex();
33+
return repository.refreshIndex();
3434
})
3535
.then(function(index) {
36-
index.read(1);
3736
index.addByPath(fileName);
3837
index.write();
3938

examples/remove-and-commit.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ var _oid;
1717
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
1818
.then(function(repo) {
1919
_repository = repo;
20-
return repo.openIndex();
20+
return repo.refreshIndex();
2121
})
2222
.then(function(index){
2323
_index = index;
24-
return _index.read();
2524
})
2625
.then(function() {
2726
//remove the file from the index...

generate/input/descriptor.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,11 @@
18421842
}
18431843
},
18441844
"git_repository_set_index": {
1845-
"ignore": true
1845+
"args": {
1846+
"index": {
1847+
"isOptional": true
1848+
}
1849+
}
18461850
},
18471851
"git_repository_set_odb": {
18481852
"ignore": true

0 commit comments

Comments
 (0)