@@ -258,19 +258,21 @@ PHP_FUNCTION(git_config_add_file_ondisk)
258
258
php_git2_t * _cfg ;
259
259
char * path = {0 };
260
260
int path_len ;
261
- zval * level ;
262
- php_git2_t * _level ;
263
- long force ;
264
-
265
- /* TODO(chobie): implement this */
266
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "git_config_add_file_ondisk not implemented yet" );
267
- return ;
261
+ long level ;
262
+ long force = 0 ;
263
+ int error = 0 ;
268
264
269
265
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
270
266
"rsrl" , & cfg , & path , & path_len , & level , & force ) == FAILURE ) {
271
267
return ;
272
268
}
269
+
273
270
ZEND_FETCH_RESOURCE (_cfg , php_git2_t * , & cfg , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
271
+ error = git_config_add_file_ondisk (PHP_GIT2_V (_cfg , config ), path , level , force );
272
+ if (php_git2_check_error (error , "git_config_add_file_ondisk" TSRMLS_CC )) {
273
+ RETURN_FALSE
274
+ }
275
+ RETURN_TRUE ;
274
276
}
275
277
276
278
/* {{{ proto resource git_config_open_ondisk(path)
@@ -279,53 +281,82 @@ PHP_FUNCTION(git_config_open_ondisk)
279
281
{
280
282
char * path = {0 };
281
283
int path_len ;
282
-
283
- /* TODO(chobie): implement this */
284
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "git_config_open_ondisk not implemented yet" );
285
- return ;
284
+ git_config * config ;
285
+ php_git2_t * result ;
286
+ int error = 0 ;
286
287
287
288
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
288
289
"s" , & path , & path_len ) == FAILURE ) {
289
290
return ;
290
291
}
292
+ error = git_config_open_ondisk (& config , path );
293
+ if (php_git2_check_error (error , "git_config_open_ondisk" TSRMLS_CC )) {
294
+ RETURN_FALSE
295
+ }
296
+ PHP_GIT2_MAKE_RESOURCE (result );
297
+ PHP_GIT2_V (result , config ) = config ;
298
+ result -> type = PHP_GIT2_TYPE_CONFIG ;
299
+ result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
300
+ result -> should_free_v = 1 ;
301
+
302
+ ZVAL_RESOURCE (return_value , result -> resource_id );
291
303
}
292
304
293
305
/* {{{ proto resource git_config_open_level(parent, level)
294
306
*/
295
307
PHP_FUNCTION (git_config_open_level )
296
308
{
297
309
zval * parent ;
298
- php_git2_t * _parent ;
299
- zval * level ;
300
- php_git2_t * _level ;
301
-
302
- /* TODO(chobie): implement this */
303
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "git_config_open_level not implemented yet" );
304
- return ;
310
+ php_git2_t * _parent , * result ;
311
+ long level ;
312
+ int error = 0 ;
313
+ git_config * out ;
305
314
306
315
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
307
- "rr " , & parent , & level ) == FAILURE ) {
316
+ "rl " , & parent , & level ) == FAILURE ) {
308
317
return ;
309
318
}
310
319
ZEND_FETCH_RESOURCE (_parent , php_git2_t * , & parent , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
320
+
321
+ error = git_config_open_level (& out , PHP_GIT2_V (_parent , config ), level );
322
+ if (php_git2_check_error (error , "git_config_open_level" TSRMLS_CC )) {
323
+ RETURN_FALSE
324
+ }
325
+ PHP_GIT2_MAKE_RESOURCE (result );
326
+ PHP_GIT2_V (result , config ) = out ;
327
+ result -> type = PHP_GIT2_TYPE_CONFIG ;
328
+ result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
329
+ result -> should_free_v = 1 ;
330
+
331
+ ZVAL_RESOURCE (return_value , result -> resource_id );
311
332
}
312
333
313
334
/* {{{ proto resource git_config_open_global(config)
314
335
*/
315
336
PHP_FUNCTION (git_config_open_global )
316
337
{
317
338
zval * config ;
318
- php_git2_t * _config ;
319
-
320
- /* TODO(chobie): implement this */
321
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "git_config_open_global not implemented yet" );
322
- return ;
339
+ php_git2_t * _config , * result ;
340
+ git_config * out ;
341
+ int error = 0 ;
323
342
324
343
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
325
344
"r" , & config ) == FAILURE ) {
326
345
return ;
327
346
}
347
+
328
348
ZEND_FETCH_RESOURCE (_config , php_git2_t * , & config , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
349
+ error = git_config_open_global (& out , PHP_GIT2_V (_config , config ));
350
+ if (php_git2_check_error (error , "git_config_open_global" TSRMLS_CC )) {
351
+ RETURN_FALSE
352
+ }
353
+ PHP_GIT2_MAKE_RESOURCE (result );
354
+ PHP_GIT2_V (result , config ) = out ;
355
+ result -> type = PHP_GIT2_TYPE_CONFIG ;
356
+ result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
357
+ result -> should_free_v = 1 ;
358
+
359
+ ZVAL_RESOURCE (return_value , result -> resource_id );
329
360
}
330
361
331
362
/* {{{ proto long git_config_refresh(cfg)
0 commit comments