Method: Rugged::Config#transaction

Defined in:
ext/rugged/rugged_config.c

#transaction {|config| ... } ⇒ Object

Perform configuration changes in a transaction.

Locks the configuration, executes the given block and stores any changes that were made to the configuration. If the block throws an exception, all changes are rolled back automatically.

During the execution of the block, configuration changes don’t get stored to disk immediately, so reading from the configuration will continue to return the values that were stored in the configuration when the transaction was started.

Yields:

  • (config)
[View source]

344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'ext/rugged/rugged_config.c', line 344

static VALUE rb_git_config_transaction(VALUE self)
{
	git_config *config;
	git_transaction *tx;
	VALUE rb_result;
	int error = 0, exception = 0;

	Data_Get_Struct(self, git_config, config);

	git_config_lock(&tx, config);

	rb_result = rb_protect(rb_yield, self, &exception);

	if (!exception)
		error = git_transaction_commit(tx);

	git_transaction_free(tx);

	if (exception)
		rb_jump_tag(exception);
	else if (error)
		rugged_exception_check(error);

	return rb_result;
}