Skip to content

Commit a93de76

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

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/tree.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,6 @@ Handle<Value> GitTree::DiffIndex(const Arguments& args) {
435435
if (args.Length() == 0 || !args[0]->IsObject()) {
436436
return ThrowException(Exception::Error(String::New("Repository repo is required.")));
437437
}
438-
if (args.Length() == 1 || !args[1]->IsObject()) {
439-
return ThrowException(Exception::Error(String::New("Index index is required.")));
440-
}
441-
if (args.Length() == 2 || !args[2]->IsObject()) {
442-
return ThrowException(Exception::Error(String::New("DiffOptions opts is required.")));
443-
}
444438

445439
if (args.Length() == 3 || !args[3]->IsFunction()) {
446440
return ThrowException(Exception::Error(String::New("Callback is required and must be a Function.")));
@@ -458,12 +452,20 @@ Handle<Value> GitTree::DiffIndex(const Arguments& args) {
458452
baton->old_tree = ObjectWrap::Unwrap<GitTree>(args.This())->GetValue();
459453
baton->indexReference = Persistent<Value>::New(args[1]);
460454
git_index * from_index;
455+
if (args[1]->IsObject()) {
461456
from_index = ObjectWrap::Unwrap<GitIndex>(args[1]->ToObject())->GetValue();
462-
baton->index = from_index;
457+
} else {
458+
from_index = 0;
459+
}
460+
baton->index = from_index;
463461
baton->optsReference = Persistent<Value>::New(args[2]);
464462
const git_diff_options * from_opts;
463+
if (args[2]->IsObject()) {
465464
from_opts = ObjectWrap::Unwrap<GitDiffOptions>(args[2]->ToObject())->GetValue();
466-
baton->opts = from_opts;
465+
} else {
466+
from_opts = 0;
467+
}
468+
baton->opts = from_opts;
467469
baton->callback = Persistent<Function>::New(Local<Function>::Cast(args[3]));
468470

469471
uv_queue_work(uv_default_loop(), &baton->request, DiffIndexWork, (uv_after_work_cb)DiffIndexAfterWork);

v0.18.0.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17010,13 +17010,15 @@
1701017010
"cType": "git_index *",
1701117011
"cppClassName": "GitIndex",
1701217012
"jsClassName": "Index",
17013+
"isOptional": true,
1701317014
"comment": "The index to diff with; repo index used if NULL."
1701417015
},
1701517016
{
1701617017
"name": "opts",
1701717018
"cType": "const git_diff_options *",
1701817019
"cppClassName": "GitDiffOptions",
1701917020
"jsClassName": "DiffOptions",
17021+
"isOptional": true,
1702017022
"comment": "Structure with options to influence diff or NULL for defaults."
1702117023
}
1702217024
],

0 commit comments

Comments
 (0)