8000 Longpaths options should take/return boolean values · nodegit/nodegit@98ffff4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 98ffff4

Browse files
committed
Longpaths options should take/return boolean values
1 parent e4e66f4 commit 98ffff4

File tree

1 file changed

+22
-9
lines changed
  • generate/templates/manual/libgit2

1 file changed

+22
-9
lines changed

generate/templates/manual/libgit2/opts.cc

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ NAN_METHOD(GitLibgit2::Opts)
66
return Nan::ThrowError("Number option is required.");
77
}
88

9-
int from_option = (int)info[0].As<v8::Number>()->Value();
9+
const int from_option = (int)info[0].As<v8::Number>()->Value();
1010

1111
git_error_clear();
1212

@@ -23,13 +23,13 @@ NAN_METHOD(GitLibgit2::Opts)
2323
to = Nan::New<Number>(option_value);
2424
break;
2525
}
26-
// GET int
26+
// GET bool
2727
case GIT_OPT_GET_WINDOWS_LONGPATHS: {
2828
int option_value;
2929
if (git_libgit2_opts(from_option, &option_value)) {
3030
return Nan::ThrowError("git_libgit2_opts failed");
3131
}
32-
to = Nan::New<Number>(option_value);
32+
to = option_value ? Nan::True() : Nan::False();
3333
break;
3434
}
3535
// GET unsigned long
@@ -67,7 +67,7 @@ NAN_METHOD(GitLibgit2::Opts)
6767
if (info.Length() < 2 || !info[1]->IsNumber()) {
6868
return Nan::ThrowError("Number option is required.");
6969
}
70-
int level = (int)info[1].As<v8::Number>()->Value();
70+
const int level = (int)info[1].As<v8::Number>()->Value();
7171
if (git_libgit2_opts(from_option, level, &option_value)) {
7272
return Nan::ThrowError("git_libgit2_opts failed");
7373
}
@@ -84,30 +84,43 @@ NAN_METHOD(GitLibgit2::Opts)
8484
case GIT_OPT_ENABLE_FSYNC_GITDIR:
8585
case GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION:
8686
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: {
8988
if (info.Length() < 2 || !info[1]->IsNumber()) {
9089
return Nan::ThrowError("Number option is required.");
9190
}
92-
int option_arg = (int)info[1].As<v8::Number>()->Value();
91+
const int option_arg = (int)info[1].As<v8::Number>()->Value();
9392
if (git_libgit2_opts(from_option, option_arg)) {
9493
return Nan::ThrowError("git_libgit2_opts failed");
9594
}
9695
to = Nan::New<Number>(0);
9796
break;
9897
}
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+
}
99112
// SET size_t
100113
case GIT_OPT_SET_MWINDOW_SIZE:
101114
case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT:
102115
case GIT_OPT_SET_PACK_MAX_OBJECTS: {
103116
if (info.Length() < 2 || !info[1]->IsNumber()) {
104117
return Nan::ThrowError("Number option is required.");
105118
}
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();
107120
if (git_libgit2_opts(from_option, option_arg)) {
108121
return Nan::ThrowError("git_libgit2_opts failed");
109122
}
110-
to = Nan::New<Number>(0);
123+
to = Nan::Undefined();
111124
break;
112125
}
113126
default: {

0 commit comments

Comments
 (0)
0