diff --git a/src/index.cc b/src/index.cc index f54f9c790..191c6ccfe 100644 --- a/src/index.cc +++ b/src/index.cc @@ -771,12 +771,6 @@ Handle GitIndex::IndexToWorkdir(const Arguments& args) { if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Index index is required."))); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); - } if (args.Length() == 3 || !args[3]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -792,12 +786,20 @@ Handle GitIndex::IndexToWorkdir(const Arguments& args) { baton->repo = from_repo; baton->indexReference = Persistent::New(args[1]); git_index * from_index; + if (args[1]->IsObject()) { from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->index = from_index; + } else { + from_index = 0; + } + baton->index = from_index; baton->optsReference = Persistent::New(args[2]); const git_diff_options * from_opts; + if (args[2]->IsObject()) { from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->opts = from_opts; + } else { + from_opts = 0; + } + baton->opts = from_opts; baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); diff --git a/v0.18.0.json b/v0.18.0.json index 9ae029ae2..5c800ca1d 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -5439,6 +5439,7 @@ "cType": "git_index *", "cppClassName": "GitIndex", "jsClassName": "Index", + "isOptional": true, "comment": "The index to diff from; repo index used if NULL." }, { @@ -5446,6 +5447,7 @@ "cType": "const git_diff_options *", "cppClassName": "GitDiffOptions", "jsClassName": "DiffOptions", + "isOptional": true, "comment": "Structure with options to influence diff or NULL for defaults." } ],