From 19211752b6c6bd2d1a5980f5a2dc3e78ecc97add Mon Sep 17 00:00:00 2001 From: Kris Ciccarello Date: Mon, 7 Oct 2013 10:28:06 -0400 Subject: [PATCH 1/2] Changed v0.18.0.json so diffWorkDir DiffOptions argument is optional. Added .idea to .gitignore to support webstorm. --- .gitignore | 1 + src/tree.cc | 9 +++++---- v0.18.0.json | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f1c077584..3c15360fc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ /out /test.git /test/.reposCache +.idea diff --git a/src/tree.cc b/src/tree.cc index 1ce6f5098..4096d945b 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -536,9 +536,6 @@ Handle GitTree::DiffWorkDir(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("DiffOptions opts is required."))); - } if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -556,8 +553,12 @@ Handle GitTree::DiffWorkDir(const Arguments& args) { baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); baton->optsReference = Persistent::New(args[1]); const git_diff_options * from_opts; + if (args[1]->IsObject()) { from_opts = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->opts = from_opts; + } else { + from_opts = 0; + } + baton->opts = from_opts; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, DiffWorkDirWork, (uv_after_work_cb)DiffWorkDirAfterWork); diff --git a/v0.18.0.json b/v0.18.0.json index b58864818..1fe9ce996 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -17064,6 +17064,7 @@ "cType": "const git_diff_options *", "cppClassName": "GitDiffOptions", "jsClassName": "DiffOptions", + "isOptional": true, "comment": "Structure with options to influence diff or NULL for defaults." } ], From a93de760bbc4018e6372b5fb0aee39bc0cbb0ce6 Mon Sep 17 00:00:00 2001 From: Kris Ciccarello Date: Mon, 7 Oct 2013 21:04:42 -0400 Subject: [PATCH 2/2] Updated v0.18.0.json to make the index and DiffOptions arguments in tree.diffIndex optional (libgit2 supports null for both) --- src/tree.cc | 18 ++++++++++-------- v0.18.0.json | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/tree.cc b/src/tree.cc index 4096d945b..398012ddf 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -435,12 +435,6 @@ Handle GitTree::DiffIndex(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."))); @@ -458,12 +452,20 @@ Handle GitTree::DiffIndex(const Arguments& args) { baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); 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, DiffIndexWork, (uv_after_work_cb)DiffIndexAfterWork); diff --git a/v0.18.0.json b/v0.18.0.json index 1fe9ce996..9ae029ae2 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -17010,6 +17010,7 @@ "cType": "git_index *", "cppClassName": "GitIndex", "jsClassName": "Index", + "isOptional": true, "comment": "The index to diff with; repo index used if NULL." }, { @@ -17017,6 +17018,7 @@ "cType": "const git_diff_options *", "cppClassName": "GitDiffOptions", "jsClassName": "DiffOptions", + "isOptional": true, "comment": "Structure with options to influence diff or NULL for defaults." } ],