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