diff --git a/lib/src/bindings/config.dart b/lib/src/bindings/config.dart index d8e8eb3..f3e4825 100644 --- a/lib/src/bindings/config.dart +++ b/lib/src/bindings/config.dart @@ -140,11 +140,11 @@ String getValue(Pointer cfg, String variable) { /// highest level (usually the local one). /// /// Throws a [LibGit2Error] if error occured. -void setBool(Pointer cfg, String name, bool value) { - final nameC = name.toNativeUtf8().cast(); +void setBool(Pointer cfg, String variable, bool value) { + final name = variable.toNativeUtf8().cast(); final valueC = value ? 1 : 0; - final error = libgit2.git_config_set_bool(cfg, nameC, valueC); - calloc.free(nameC); + final error = libgit2.git_config_set_bool(cfg, name, valueC); + calloc.free(name); if (error < 0) { throw LibGit2Error(libgit2.git_error_last()); @@ -155,10 +155,10 @@ void setBool(Pointer cfg, String name, bool value) { /// highest level (usually the local one). /// /// Throws a [LibGit2Error] if error occured. -void setInt(Pointer cfg, String name, int value) { - final nameC = name.toNativeUtf8().cast(); - final error = libgit2.git_config_set_int64(cfg, nameC, value); - calloc.free(nameC); +void setInt(Pointer cfg, String variable, int value) { + final name = variable.toNativeUtf8().cast(); + final error = libgit2.git_config_set_int64(cfg, name, value); + calloc.free(name); if (error < 0) { throw LibGit2Error(libgit2.git_error_last()); @@ -169,11 +169,11 @@ void setInt(Pointer cfg, String name, int value) { /// highest level (usually the local one). /// /// Throws a [LibGit2Error] if error occured. -void setString(Pointer cfg, String name, String value) { - final nameC = name.toNativeUtf8().cast(); +void setString(Pointer cfg, String variable, String value) { + final name = variable.toNativeUtf8().cast(); final valueC = value.toNativeUtf8().cast(); - final error = libgit2.git_config_set_string(cfg, nameC, valueC); - calloc.free(nameC); + final error = libgit2.git_config_set_string(cfg, name, valueC); + calloc.free(name); calloc.free(valueC); if (error < 0) { @@ -204,10 +204,10 @@ Map getEntries(Pointer cfg) { /// (usually the local one). /// /// Throws a [LibGit2Error] if error occured. -void deleteVariable(Pointer cfg, String name) { - final nameC = name.toNativeUtf8().cast(); - final error = libgit2.git_config_delete_entry(cfg, nameC); - calloc.free(nameC); +void deleteVariable(Pointer cfg, String variable) { + final name = variable.toNativeUtf8().cast(); + final error = libgit2.git_config_delete_entry(cfg, name); + calloc.free(name); if (error < 0) { throw LibGit2Error(libgit2.git_error_last()); @@ -220,14 +220,14 @@ void deleteVariable(Pointer cfg, String name) { /// values which match the pattern. List getMultivar( Pointer cfg, - String name, + String variable, String? regexp, ) { - final nameC = name.toNativeUtf8().cast(); + final name = variable.toNativeUtf8().cast(); final regexpC = regexp?.toNativeUtf8().cast() ?? nullptr; final iterator = calloc>(); final entry = calloc>(); - libgit2.git_config_multivar_iterator_new(iterator, cfg, nameC, regexpC); + libgit2.git_config_multivar_iterator_new(iterator, cfg, name, regexpC); var error = 0; final entries = []; @@ -240,7 +240,7 @@ List getMultivar( } } - calloc.free(nameC); + calloc.free(name); calloc.free(regexpC); calloc.free(iterator); calloc.free(entry); @@ -254,16 +254,16 @@ List getMultivar( /// The regular expression is applied case-sensitively on the value. void setMultivar( Pointer cfg, - String name, + String variable, String regexp, String value, ) { - final nameC = name.toNativeUtf8().cast(); + final name = variable.toNativeUtf8().cast(); final regexpC = regexp.toNativeUtf8().cast(); final valueC = value.toNativeUtf8().cast(); - libgit2.git_config_set_multivar(cfg, nameC, regexpC, valueC); + libgit2.git_config_set_multivar(cfg, name, regexpC, valueC); - calloc.free(nameC); + calloc.free(name); calloc.free(regexpC); calloc.free(valueC); } diff --git a/lib/src/config.dart b/lib/src/config.dart index 81004d4..934840c 100644 --- a/lib/src/config.dart +++ b/lib/src/config.dart @@ -134,33 +134,33 @@ class Config { } } - /// Deletes variable from the config file with the highest level + /// Deletes [variable] from the config file with the highest level /// (usually the local one). /// /// Throws a [LibGit2Error] if error occured. - void deleteVariable(String key) { + void deleteVariable(String variable) { try { - config.deleteVariable(configPointer.value, key); + config.deleteVariable(configPointer.value, variable); } catch (e) { rethrow; } } - /// Returns list of values for multivar [key] + /// Returns list of values for multivar [variable] /// /// If [regexp] is present, then the iterator will only iterate over all /// values which match the pattern. - List getMultivar(String key, {String? regexp}) { - return config.getMultivar(configPointer.value, key, regexp); + List getMultivar(String variable, {String? regexp}) { + return config.getMultivar(configPointer.value, variable, regexp); } - /// Sets the [value] of a multivar [key] in the config file with the + /// Sets the [value] of a multivar [variable] in the config file with the /// highest level (usually the local one). /// /// The [regexp] is applied case-sensitively on the value. - /// Empty [regexp] sets [value] for all values of a multivar [key] - void setMultivar(String key, String regexp, String value) { - config.setMultivar(configPointer.value, key, regexp, value); + /// Empty [regexp] sets [value] for all values of a multivar [variable] + void setMultivar(String variable, String regexp, String value) { + config.setMultivar(configPointer.value, variable, regexp, value); } /// Releases memory allocated for config object.