99
1010#include " ../include/branch.h"
1111
12- #include " ../include/functions/string.h"
13-
1412using namespace v8 ;
1513using namespace node ;
1614
@@ -87,15 +85,20 @@ Handle<Value> Branch::Create(const Arguments& args) {
8785 }
8886
8987 git_reference *out = NULL ;
88+ git_repository * from_repo = ObjectWrap::Unwrap<GitRepo>(args[0 ]->ToObject ())->GetValue ();
89+ String::Utf8Value branch_name (args[1 ]->ToString ());
90+ const char * from_branch_name = strdup (*branch_name);
91+ const git_commit * from_target = ObjectWrap::Unwrap<GitCommit>(args[2 ]->ToObject ())->GetValue ();
92+ int from_force = (int ) args[3 ]->ToInt32 ()->Value ();
9093
9194 int result = git_branch_create (
9295 &out
93- , ObjectWrap::Unwrap<GitRepo>(args[ 0 ]-> ToObject ())-> GetValue ()
94- , stringArgToString (args[ 1 ]-> ToString ()). c_str ()
95- , ObjectWrap::Unwrap<GitCommit>(args[ 2 ]-> ToObject ())-> GetValue ()
96- , ( int ) args[ 3 ]-> ToInt32 ()-> Value ()
96+ , from_repo
97+ , from_branch_name
98+ , from_target
99+ , from_force
97100 );
98-
101+ delete from_branch_name;
99102 if (result != GIT_OK) {
100103 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
101104 }
@@ -111,11 +114,11 @@ Handle<Value> Branch::Delete(const Arguments& args) {
111114 return ThrowException (Exception::Error (String::New (" Reference branch is required." )));
112115 }
113116
117+ git_reference * from_branch = ObjectWrap::Unwrap<GitReference>(args[0 ]->ToObject ())->GetValue ();
114118
115119 int result = git_branch_delete (
116- ObjectWrap::Unwrap<GitReference>(args[ 0 ]-> ToObject ())-> GetValue ()
120+ from_branch
117121 );
118-
119122 if (result != GIT_OK) {
120123 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
121124 }
@@ -138,14 +141,17 @@ Handle<Value> Branch::Foreach(const Arguments& args) {
138141 return ThrowException (Exception::Error (String::New (" void payload is required." )));
139142 }
140143
144+ git_repository * from_repo = ObjectWrap::Unwrap<GitRepo>(args[0 ]->ToObject ())->GetValue ();
145+ unsigned int from_list_flags = (unsigned int ) args[1 ]->ToUint32 ()->Value ();
146+ git_branch_foreach_cb from_branch_cb = ObjectWrap::Unwrap<BranchForeachCb>(args[2 ]->ToObject ())->GetValue ();
147+ void * from_payload = ObjectWrap::Unwrap<void >(args[3 ]->ToObject ())->GetValue ();
141148
142149 int result = git_branch_foreach (
143- ObjectWrap::Unwrap<GitRepo>(args[ 0 ]-> ToObject ())-> GetValue ()
144- , ( unsigned int ) args[ 1 ]-> ToUint32 ()-> Value ()
145- , ObjectWrap::Unwrap<BranchForeachCb>(args[ 2 ]-> ToObject ())-> GetValue ()
146- , ObjectWrap::Unwrap< void >(args[ 3 ]-> ToObject ())-> GetValue ()
150+ from_repo
151+ , from_list_flags
152+ , from_branch_cb
153+ , from_payload
147154 );
148-
149155 if (result != GIT_OK) {
150156 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
151157 }
@@ -166,14 +172,18 @@ Handle<Value> Branch::Move(const Arguments& args) {
166172 }
167173
168174 git_reference *out = NULL ;
175+ git_reference * from_branch = ObjectWrap::Unwrap<GitReference>(args[0 ]->ToObject ())->GetValue ();
176+ String::Utf8Value new_branch_name (args[1 ]->ToString ());
177+ const char * from_new_branch_name = strdup (*new_branch_name);
178+ int from_force = (int ) args[2 ]->ToInt32 ()->Value ();
169179
170180 int result = git_branch_move (
171181 &out
172- , ObjectWrap::Unwrap<GitReference>(args[ 0 ]-> ToObject ())-> GetValue ()
173- , stringArgToString (args[ 1 ]-> ToString ()). c_str ()
174- , ( int ) args[ 2 ]-> ToInt32 ()-> Value ()
182+ , from_branch
183+ , from_new_branch_name
184+ , from_force
175185 );
176-
186+ delete from_new_branch_name;
177187 if (result != GIT_OK) {
178188 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
179189 }
@@ -196,14 +206,18 @@ Handle<Value> Branch::Lookup(const Arguments& args) {
196206 }
197207
198208 git_reference *out = NULL ;
209+ git_repository * from_repo = ObjectWrap::Unwrap<GitRepo>(args[0 ]->ToObject ())->GetValue ();
210+ String::Utf8Value branch_name (args[1 ]->ToString ());
211+ const char * from_branch_name = strdup (*branch_name);
212+ git_branch_t from_branch_type = ObjectWrap::Unwrap<BranchT>(args[2 ]->ToObject ())->GetValue ();
199213
200214 int result = git_branch_lookup (
201215 &out
202- , ObjectWrap::Unwrap<GitRepo>(args[ 0 ]-> ToObject ())-> GetValue ()
203- , stringArgToString (args[ 1 ]-> ToString ()). c_str ()
204- , ObjectWrap::Unwrap<BranchT>(args[ 2 ]-> ToObject ())-> GetValue ()
216+ , from_repo
217+ , from_branch_name
218+ , from_branch_type
205219 );
206-
220+ delete from_branch_name;
207221 if (result != GIT_OK) {
208222 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
209223 }
@@ -220,12 +234,12 @@ Handle<Value> Branch::Name(const Arguments& args) {
220234 }
221235
222236 const char *out = NULL ;
237+ git_reference * from_ref = ObjectWrap::Unwrap<GitReference>(args[0 ]->ToObject ())->GetValue ();
223238
224239 int result = git_branch_name (
225240 &out
226- , ObjectWrap::Unwrap<GitReference>(args[ 0 ]-> ToObject ())-> GetValue ()
241+ , from_ref
227242 );
228-
229243 if (result != GIT_OK) {
230244 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
231245 }
@@ -242,12 +256,12 @@ Handle<Value> Branch::Upstream(const Arguments& args) {
242256 }
243257
244258 git_reference *out = NULL ;
259+ git_reference * from_branch = ObjectWrap::Unwrap<GitReference>(args[0 ]->ToObject ())->GetValue ();
245260
246261 int result = git_branch_upstream (
247262 &out
248- , ObjectWrap::Unwrap<GitReference>(args[ 0 ]-> ToObject ())-> GetValue ()
263+ , from_branch
249264 );
250-
251265 if (result != GIT_OK) {
252266 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
253267 }
@@ -266,12 +280,15 @@ Handle<Value> Branch::SetUpstream(const Arguments& args) {
266280 return ThrowException (Exception::Error (String::New (" String upstream_name is required." )));
267281 }
268282
283+ git_reference * from_branch = ObjectWrap::Unwrap<GitReference>(args[0 ]->ToObject ())->GetValue ();
284+ String::Utf8Value upstream_name (args[1 ]->ToString ());
285+ const char * from_upstream_name = strdup (*upstream_name);
269286
270287 int result = git_branch_set_upstream (
271- ObjectWrap::Unwrap<GitReference>(args[ 0 ]-> ToObject ())-> GetValue ()
272- , stringArgToString (args[ 1 ]-> ToString ()). c_str ()
288+ from_branch
289+ , from_upstream_name
273290 );
274-
291+ delete from_upstream_name;
275292 if (result != GIT_OK) {
276293 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
277294 }
@@ -294,14 +311,21 @@ Handle<Value> Branch::UpstreamName(const Arguments& args) {
294311 return ThrowException (Exception::Error (String::New (" String canonical_branch_name is required." )));
295312 }
296313
314+ String::Utf8Value tracking_branch_name_out (args[0 ]->ToString ());
315+ char * from_tracking_branch_name_out = strdup (*tracking_branch_name_out);
316+ size_t from_buffer_size = (size_t ) args[1 ]->ToUint32 ()->Value ();
317+ git_repository * from_repo = ObjectWrap::Unwrap<GitRepo>(args[2 ]->ToObject ())->GetValue ();
318+ String::Utf8Value canonical_branch_name (args[3 ]->ToString ());
319+ const char * from_canonical_branch_name = strdup (*canonical_branch_name);
297320
298321 int result = git_branch_upstream_name (
299- stringArgToString (args[ 0 ]-> ToString ()). c_str ()
300- , ( size_t ) args[ 1 ]-> ToUint32 ()-> Value ()
301- , ObjectWrap::Unwrap<GitRepo>(args[ 2 ]-> ToObject ())-> GetValue ()
302- , stringArgToString (args[ 3 ]-> ToString ()). c_str ()
322+ from_tracking_branch_name_out
323+ , from_buffer_size
324+ , from_repo
325+ , from_canonical_branch_name
303326 );
304-
327+ delete from_tracking_branch_name_out;
328+ delete from_canonical_branch_name;
305329 if (result != GIT_OK) {
306330 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
307331 }
@@ -315,11 +339,11 @@ Handle<Value> Branch::IsHead(const Arguments& args) {
315339 return ThrowException (Exception::Error (String::New (" Reference branch is required." )));
316340 }
317341
342+ git_reference * from_branch = ObjectWrap::Unwrap<GitReference>(args[0 ]->ToObject ())->GetValue ();
318343
319344 int result = git_branch_is_head (
320- ObjectWrap::Unwrap<GitReference>(args[ 0 ]-> ToObject ())-> GetValue ()
345+ from_branch
321346 );
322-
323347 if (result != GIT_OK) {
324348 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
325349 }
@@ -342,14 +366,21 @@ Handle<Value> Branch::RemoteName(const Arguments& args) {
342366 return ThrowException (Exception::Error (String::New (" String canonical_branch_name is required." )));
343367 }
344368
369+ String::Utf8Value remote_name_out (args[0 ]->ToString ());
370+ char * from_remote_name_out = strdup (*remote_name_out);
371+ size_t from_buffer_size = (size_t ) args[1 ]->ToUint32 ()->Value ();
372+ git_repository * from_repo = ObjectWrap::Unwrap<GitRepo>(args[2 ]->ToObject ())->GetValue ();
373+ String::Utf8Value canonical_branch_name (args[3 ]->ToString ());
374+ const char * from_canonical_branch_name = strdup (*canonical_branch_name);
345375
346376 int result = git_branch_remote_name (
347- stringArgToString (args[ 0 ]-> ToString ()). c_str ()
348- , ( size_t ) args[ 1 ]-> ToUint32 ()-> Value ()
349- , ObjectWrap::Unwrap<GitRepo>(args[ 2 ]-> ToObject ())-> GetValue ()
350- , stringArgToString (args[ 3 ]-> ToString ()). c_str ()
377+ from_remote_name_out
378+ , from_buffer_size
379+ , from_repo
380+ , from_canonical_branch_name
351381 );
352-
382+ delete from_remote_name_out;
383+ delete from_canonical_branch_name;
353384 if (result != GIT_OK) {
354385 return ThrowException (Exception::Error (String::New (giterr_last ()->message )));
355386 }
0 commit comments