@@ -306,6 +306,28 @@ static VALUE rb_git_config_open_default(VALUE klass)
306
306
return rugged_config_new (klass , Qnil , cfg );
307
307
}
308
308
309
+ /*
310
+ * call-seq:
311
+ * config.snapshot -> snapshot
312
+ *
313
+ * Create a snapshot of the configuration.
314
+ *
315
+ * Provides a consistent, read-only view of the configuration for
316
+ * looking up complex values from a configuration.
317
+ */
318
+ static VALUE rb_git_config_snapshot (VALUE self )
319
+ {
320
+ git_config * config , * snapshot ;
321
+
322
+ Data_Get_Struct (self , git_config , config );
323
+
324
+ rugged_exception_check (
325
+ git_config_snapshot (& snapshot , config )
326
+ );
327
+
328
+ return rugged_config_new (rb_obj_class (self ), Qnil , snapshot );
329
+ }
330
+
309
331
void Init_rugged_config (void )
310
332
{
311
333
/*
@@ -330,4 +352,5 @@ void Init_rugged_config(void)
330
352
rb_define_method (rb_cRuggedConfig , "each" , rb_git_config_each_pair , 0 );
331
353
rb_define_method (rb_cRuggedConfig , "to_hash" , rb_git_config_to_hash , 0 );
332
354
355
+ rb_define_method (rb_cRuggedConfig , "snapshot" , rb_git_config_snapshot , 0 );
333
356
}
0 commit comments