@@ -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);
0 commit comments