@@ -6,7 +6,7 @@ NAN_METHOD(GitLibgit2::Opts)
6
6
return Nan::ThrowError (" Number option is required." );
7
7
}
8
8
9
- int from_option = (int )info[0 ].As <v8::Number>()->Value ();
9
+ const int from_option = (int )info[0 ].As <v8::Number>()->Value ();
10
10
11
11
git_error_clear ();
12
12
@@ -23,13 +23,13 @@ NAN_METHOD(GitLibgit2::Opts)
23
23
to = Nan::New<Number>(option_value);
24
24
break ;
25
25
}
26
- // GET int
26
+ // GET bool
27
27
case GIT_OPT_GET_WINDOWS_LONGPATHS: {
28
28
int option_value;
29
29
if (git_libgit2_opts (from_option, &option_value)) {
30
30
return Nan::ThrowError (" git_libgit2_opts failed" );
31
31
}
32
- to = Nan::New<Number>(option_value );
32
+ to = option_value ? Nan::True () : Nan::False ( );
33
33
break ;
34
34
}
35
35
// GET unsigned long
@@ -67,7 +67,7 @@ NAN_METHOD(GitLibgit2::Opts)
67
67
if (info.Length () < 2 || !info[1 ]->IsNumber ()) {
68
68
return Nan::ThrowError (" Number option is required." );
69
69
}
70
- int level = (int )info[1 ].As <v8::Number>()->Value ();
70
+ const int level = (int )info[1 ].As <v8::Number>()->Value ();
71
71
if (git_libgit2_opts (from_option, level, &option_value)) {
72
72
return Nan::ThrowError (" git_libgit2_opts failed" );
73
73
}
@@ -84,30 +84,43 @@ NAN_METHOD(GitLibgit2::Opts)
84
84
case GIT_OPT_ENABLE_FSYNC_GITDIR:
85
85
case GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION:
86
86
case GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY:
87
- case GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS:
88
- case GIT_OPT_SET_WINDOWS_LONGPATHS: {
87
+ case GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS: {
89
88
if (info.Length () < 2 || !info[1 ]->IsNumber ()) {
90
89
return Nan::ThrowError (" Number option is required." );
91
90
}
92
- int option_arg = (int )info[1 ].As <v8::Number>()->Value ();
91
+ const int option_arg = (int )info[1 ].As <v8::Number>()->Value ();
93
92
if (git_libgit2_opts (from_option, option_arg)) {
94
93
return Nan::ThrowError (" git_libgit2_opts failed" );
95
94
}
96
95
to = Nan::New<Number>(0 );
97
96
break ;
98
97
}
98
+ // SET bool
99
+ case GIT_OPT_SET_WINDOWS_LONGPATHS: {
100
+ int option_arg;
101
+ if (info.Length () < 2 ) {
102
+ option_arg = 0 ;
103
+ } else {
104
+ option_arg = info[1 ]->BooleanValue (info.GetIsolate ()) ? 1 : 0 ;
105
+ }
106
+ if (git_libgit2_opts (from_option, option_arg)) {
107
+ return Nan::ThrowError (" git_libgit2_opts failed" );
108
+ }
109
+ to = Nan::Undefined ();
110
+ break ;
111
+ }
99
112
// SET size_t
100
113
case GIT_OPT_SET_MWINDOW_SIZE:
101
114
case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT:
102
115
case GIT_OPT_SET_PACK_MAX_OBJECTS: {
103
116
if (info.Length () < 2 || !info[1 ]->IsNumber ()) {
104
117
return Nan::ThrowError (" Number option is required." );
105
118
}
106
- size_t option_arg = (size_t )info[1 ].As <v8::Number>()->Value ();
119
+ const size_t option_arg = (size_t )info[1 ].As <v8::Number>()->Value ();
107
120
if (git_libgit2_opts (from_option, option_arg)) {
108
121
return Nan::ThrowError (" git_libgit2_opts failed" );
109
122
}
110
- to = Nan::New<Number>( 0 );
123
+ to = Nan::Undefined ( );
111
124
break ;
112
125
}
113
126
default : {
0 commit comments