Skip to content

Commit 7f085b3

Browse files
committed
Updated v0.18.0.json to make the index and DiffOptions arguments in Index.indexToWorkdir optional (libgit2 supports null for both)
1 parent a93de76 commit 7f085b3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/index.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,6 @@ Handle<Value> GitIndex::IndexToWorkdir(const Arguments& args) {
771771
if (args.Length() == 0 || !args[0]->IsObject()) {
772772
return ThrowException(Exception::Error(String::New("Repository repo is required.")));
773773
}
774-
if (args.Length() == 1 || !args[1]->IsObject()) {
775-
return ThrowException(Exception::Error(String::New("Index index is required.")));
776-
}
777-
if (args.Length() == 2 || !args[2]->IsObject()) {
778-
return ThrowException(Exception::Error(String::New("DiffOptions opts is required.")));
779-
}
780774

781775
if (args.Length() == 3 || !args[3]->IsFunction()) {
782776
return ThrowException(Exception::Error(String::New("Callback is required and must be a Function.")));
@@ -792,12 +786,20 @@ Handle<Value> GitIndex::IndexToWorkdir(const Arguments& args) {
792786
baton->repo = from_repo;
793787
baton->indexReference = Persistent<Value>::New(args[1]);
794788
git_index * from_index;
789+
if (args[1]->IsObject()) {
795790
from_index = ObjectWrap::Unwrap<GitIndex>(args[1]->ToObject())->GetValue();
796-
baton->index = from_index;
791+
} else {
792+
from_index = 0;
793+
}
794+
baton->index = from_index;
797795
baton->optsReference = Persistent<Value>::New(args[2]);
798796
const git_diff_options * from_opts;
797+
if (args[2]->IsObject()) {
799798
from_opts = ObjectWrap::Unwrap<GitDiffOptions>(args[2]->ToObject())->GetValue();
800-
baton->opts = from_opts;
799+
} else {
800+
from_opts = 0;
801+
}
802+
baton->opts = from_opts;
801803
baton->callback = Persistent<Function>::New(Local<Function>::Cast(args[3]));
802804

803805
uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork);

v0.18.0.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5439,13 +5439,15 @@
54395439
"cType": "git_index *",
54405440
"cppClassName": "GitIndex",
54415441
"jsClassName": "Index",
5442+
"isOptional": true,
54425443
"comment": "The index to diff from; repo index used if NULL."
54435444
},
54445445
{
54455446
"name": "opts",
54465447
"cType": "const git_diff_options *",
54475448
"cppClassName": "GitDiffOptions",
54485449
"jsClassName": "DiffOptions",
5450+
"isOptional": true,
54495451
"comment": "Structure with options to influence diff or NULL for defaults."
54505452
}
54515453
],

0 commit comments

Comments
 (0)