@@ -73,117 +73,46 @@ option(PyObject *self, PyObject *args)
73
73
74
74
switch (option ) {
75
75
76
+ case GIT_OPT_GET_MWINDOW_FILE_LIMIT :
77
+ case GIT_OPT_GET_MWINDOW_MAPPED_LIMIT :
76
78
case GIT_OPT_GET_MWINDOW_SIZE :
77
79
{
78
- size_t size ;
80
+ size_t value ;
79
81
80
- error = git_libgit2_opts (GIT_OPT_GET_MWINDOW_SIZE , & size );
82
+ error = git_libgit2_opts (option , & value );
81
83
if (error < 0 )
82
84
return Error_set (error );
83
85
84
- return PyLong_FromSize_t (size );
86
+ return PyLong_FromSize_t (value );
85
87
}
86
88
89
+ case GIT_OPT_SET_MWINDOW_FILE_LIMIT :
90
+ case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT :
87
91
case GIT_OPT_SET_MWINDOW_SIZE :
88
92
{
89
- size_t size ;
90
- PyObject * py_size ;
91
-
92
- py_size = PyTuple_GetItem (args , 1 );
93
- if (!py_size )
93
+ PyObject * py_value = PyTuple_GetItem (args , 1 );
94
+ if (!py_value )
94
95
return NULL ;
95
96
96
- if (!PyLong_Check (py_size ))
97
- return Error_type_error (
98
- "size should be an integer, got %.200s" , py_size );
97
+ if (!PyLong_Check (py_value ))
98
+ return Error_type_error ("expected integer, got %.200s" , py_value );
99
99
100
- size = PyLong_AsSize_t (py_size );
101
- error = git_libgit2_opts (GIT_OPT_SET_MWINDOW_SIZE , size );
100
+ size_t value = PyLong_AsSize_t (py_value );
101
+ error = git_libgit2_opts (option , value );
102
102
if (error < 0 )
103
103
return Error_set (error );
104
104
105
105
Py_RETURN_NONE ;
106
106
}
107
107
108
- case GIT_OPT_GET_MWINDOW_MAPPED_LIMIT :
109
- {
110
- size_t limit ;
111
-
112
- error = git_libgit2_opts (GIT_OPT_GET_MWINDOW_MAPPED_LIMIT , & limit );
113
- if (error < 0 )
114
- return Error_set (error );
115
-
116
- return PyLong_FromSize_t (limit );
117
- }
118
-
119
- case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT :
120
- {
121
- size_t limit ;
122
- PyObject * py_limit ;
123
-
124
- py_limit = PyTuple_GetItem (args , 1 );
125
- if (!py_limit )
126
- return NULL ;
127
-
128
- if (PyLong_Check (py_limit )) {
129
- limit = PyLong_AsSize_t (py_limit );
130
- } else if (PyLong_Check (py_limit )) {
131
- limit = PyLong_AsSize_t (py_limit );
132
- } else {
133
- return Error_type_error (
134
- "limit should be an integer, got %.200s" , py_limit );
135
- }
136
-
137
- error = git_libgit2_opts (GIT_OPT_SET_MWINDOW_MAPPED_LIMIT , limit );
138
- if (error < 0 )
139
- return Error_set (error );
140
-
141
- Py_RETURN_NONE ;
142
- }
143
-
144
- case GIT_OPT_GET_MWINDOW_FILE_LIMIT :
145
- {
146
- size_t limit ;
147
-
148
- error = git_libgit2_opts (GIT_OPT_GET_MWINDOW_FILE_LIMIT , & limit );
149
- if (error < 0 )
150
- return Error_set (error );
151
-
152
- return PyLong_FromSize_t (limit );
153
- }
154
-
155
- case GIT_OPT_SET_MWINDOW_FILE_LIMIT :
156
- {
157
- size_t limit ;
158
- PyObject * py_limit ;
159
-
160
- py_limit = PyTuple_GetItem (args , 1 );
161
- if (!py_limit )
162
- return NULL ;
163
-
164
- if (!PyLong_Check (py_limit ))
165
- return Error_type_error (
166
- "size should be an integer, got %.200s" , py_limit );
167
-
168
- limit = PyLong_AsSize_t (py_limit );
169
- error = git_libgit2_opts (GIT_OPT_SET_MWINDOW_SIZE , limit );
170
- if (error < 0 )
171
- return Error_set (error );
172
-
173
- Py_RETURN_NONE ;
174
- }
175
-
176
108
case GIT_OPT_GET_SEARCH_PATH :
177
109
{
178
- PyObject * py_level ;
179
-
180
- py_level = PyTuple_GetItem (args , 1 );
110
+ PyObject * py_level = PyTuple_GetItem (args , 1 );
181
111
if (!py_level )
182
112
return NULL ;
183
113
184
114
if (!PyLong_Check (py_level ))
185
- return Error_type_error (
186
- "level should be an integer, got %.200s" , py_level );
115
+ return Error_type_error ("level should be an integer, got %.200s" , py_level );
187
116
188
117
return get_search_path (PyLong_AsLong (py_level ));
189
118
}
@@ -205,7 +134,7 @@ option(PyObject *self, PyObject *args)
205
134
if (!path )
206
135
return NULL ;
207
136
208
- int err = git_libgit2_opts (GIT_OPT_SET_SEARCH_PATH , PyLong_AsLong (py_level ), path );
137
+ int err = git_libgit2_opts (option , PyLong_AsLong (py_level ), path );
209
138
if (err < 0 )
210
139
return Error_set (err );
211
140
@@ -232,8 +161,7 @@ option(PyObject *self, PyObject *args)
232
161
233
162
object_type = PyLong_AsLong (py_object_type );
234
163
limit = PyLong_AsSize_t (py_limit );
235
- error = git_libgit2_opts (
236
- GIT_OPT_SET_CACHE_OBJECT_LIMIT , object_type , limit );
164
+ error = git_libgit2_opts (option , object_type , limit );
237
165
238
166
if (error < 0 )
239
167
return Error_set (error );
@@ -255,7 +183,7 @@ option(PyObject *self, PyObject *args)
255
183
"max_size should be an integer, got %.200s" , py_max_size );
256
184
257
185
max_size = PyLong_AsSize_t (py_max_size );
258
- error = git_libgit2_opts (GIT_OPT_SET_CACHE_MAX_SIZE , max_size );
186
+ error = git_libgit2_opts (option , max_size );
259
187
if (error < 0 )
260
188
return Error_set (error );
261
189
@@ -268,7 +196,7 @@ option(PyObject *self, PyObject *args)
268
196
size_t allowed ;
269
197
PyObject * tup = PyTuple_New (2 );
270
198
271
- error = git_libgit2_opts (GIT_OPT_GET_CACHED_MEMORY , & current , & allowed );
199
+ error = git_libgit2_opts (option , & current , & allowed );
272
200
if (error < 0 )
273
201
return Error_set (error );
274
202
@@ -307,7 +235,7 @@ option(PyObject *self, PyObject *args)
307
235
if (PyUnicode_Check (py_dir ) || PyBytes_Check (py_dir ))
308
236
dir_path = pgit_borrow_fsdefault (py_dir , & tvalue_dir );
309
237
310
- err = git_libgit2_opts (GIT_OPT_SET_SSL_CERT_LOCATIONS , file_path , dir_path );
238
+ err = git_libgit2_opts (option , file_path , dir_path );
311
239
Py_XDECREF (tvalue_file );
312
240
Py_XDECREF (tvalue_dir );
313
241
@@ -334,18 +262,15 @@ option(PyObject *self, PyObject *args)
334
262
case GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS :
335
263
case GIT_OPT_SET_OWNER_VALIDATION :
336
264
{
337
- PyObject * py_enabled ;
338
- int enabled ;
339
-
340
- py_enabled = PyTuple_GetItem (args , 1 );
341
- if (!py_enabled )
265
+ PyObject * py_value = PyTuple_GetItem (args , 1 );
266
+ if (!py_value )
342
267
return NULL ;
343
268
344
- if (!PyLong_Check (py_enabled ))
345
- return Error_type_error ("expected integer, got %.200s" , py_enabled );
269
+ if (!PyLong_Check (py_value ))
270
+ return Error_type_error ("expected integer, got %.200s" , py_value );
346
271
347
- enabled = PyLong_AsSize_t (py_enabled );
348
- error = git_libgit2_opts (option , enabled );
272
+ int value = PyLong_AsSize_t (py_value );
273
+ error = git_libgit2_opts (option , value );
349
274
if (error < 0 )
350
275
return Error_set (error );
351
276
0 commit comments