Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Forster <brendan@github.com>2015-05-10 13:58:18 +0300
committernulltoken <emeric.fermas@gmail.com>2015-05-15 20:31:44 +0300
commit9b26f363ad86509bbea697c9ac7bddba8e16c0c0 (patch)
tree5bff4f1b13cf9d6c8d91d4ceba97faaf118b8f9a
parent427755989df0b1c69e58affa402ef2b5d4ce6bc6 (diff)
Drop optional parameters in Configuration.cs
-rw-r--r--LibGit2Sharp.Tests/ConfigurationFixture.cs2
-rw-r--r--LibGit2Sharp/Configuration.cs66
2 files changed, 62 insertions, 6 deletions
diff --git a/LibGit2Sharp.Tests/ConfigurationFixture.cs b/LibGit2Sharp.Tests/ConfigurationFixture.cs
index 4f92ce0c..78cb71c0 100644
--- a/LibGit2Sharp.Tests/ConfigurationFixture.cs
+++ b/LibGit2Sharp.Tests/ConfigurationFixture.cs
@@ -256,7 +256,7 @@ namespace LibGit2Sharp.Tests
[Fact]
public void SettingLocalConfigurationOutsideAReposThrows()
{
- using (var config = new Configuration())
+ using (var config = new Configuration(null, null, null))
{
Assert.Throws<LibGit2SharpException>(() => config.Set("unittests.intsetting", 3));
}
diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs
index b1b57456..078ad14f 100644
--- a/LibGit2Sharp/Configuration.cs
+++ b/LibGit2Sharp/Configuration.cs
@@ -77,9 +77,26 @@ namespace LibGit2Sharp
/// Access configuration values without a repository. Generally you want to access configuration via an instance of <see cref="Repository"/> instead.
/// </summary>
/// <param name="globalConfigurationFileLocation">Path to a Global configuration file. If null, the default path for a global configuration file will be probed.</param>
+ public Configuration(string globalConfigurationFileLocation)
+ : this(null, globalConfigurationFileLocation, null, null)
+ { }
+
+ /// <summary>
+ /// Access configuration values without a repository. Generally you want to access configuration via an instance of <see cref="Repository"/> instead.
+ /// </summary>
+ /// <param name="globalConfigurationFileLocation">Path to a Global configuration file. If null, the default path for a global configuration file will be probed.</param>
+ /// <param name="xdgConfigurationFileLocation">Path to a XDG configuration file. If null, the default path for a XDG configuration file will be probed.</param>
+ public Configuration(string globalConfigurationFileLocation, string xdgConfigurationFileLocation)
+ : this(null, globalConfigurationFileLocation, xdgConfigurationFileLocation, null)
+ { }
+
+ /// <summary>
+ /// Access configuration values without a repository. Generally you want to access configuration via an instance of <see cref="Repository"/> instead.
+ /// </summary>
+ /// <param name="globalConfigurationFileLocation">Path to a Global configuration file. If null, the default path for a global configuration file will be probed.</param>
/// <param name="xdgConfigurationFileLocation">Path to a XDG configuration file. If null, the default path for a XDG configuration file will be probed.</param>
/// <param name="systemConfigurationFileLocation">Path to a System configuration file. If null, the default path for a system configuration file will be probed.</param>
- public Configuration(string globalConfigurationFileLocation = null, string xdgConfigurationFileLocation = null, string systemConfigurationFileLocation = null)
+ public Configuration(string globalConfigurationFileLocation, string xdgConfigurationFileLocation, string systemConfigurationFileLocation)
: this(null, globalConfigurationFileLocation, xdgConfigurationFileLocation, systemConfigurationFileLocation)
{
}
@@ -111,11 +128,20 @@ namespace LibGit2Sharp
#endregion
/// <summary>
+ /// Unset a configuration variable (key and value) in the local configuration.
+ /// </summary>
+ /// <param name="key">The key to unset.</param>
+ public virtual void Unset(string key)
+ {
+ Unset(key, ConfigurationLevel.Local);
+ }
+
+ /// <summary>
/// Unset a configuration variable (key and value).
/// </summary>
/// <param name="key">The key to unset.</param>
/// <param name="level">The configuration file which should be considered as the target of this operation</param>
- public virtual void Unset(string key, ConfigurationLevel level = ConfigurationLevel.Local)
+ public virtual void Unset(string key, ConfigurationLevel level)
{
Ensure.ArgumentNotNullOrEmptyString(key, "key");
@@ -210,6 +236,27 @@ namespace LibGit2Sharp
}
/// <summary>
+ /// Set a configuration value for a key in the local configuration. Keys are in the form 'section.name'.
+ /// <para>
+ /// For example in order to set the value for this in a .git\config file:
+ ///
+ /// [test]
+ /// boolsetting = true
+ ///
+ /// You would call:
+ ///
+ /// repo.Config.Set("test.boolsetting", true);
+ /// </para>
+ /// </summary>
+ /// <typeparam name="T">The configuration value type</typeparam>
+ /// <param name="key">The key parts</param>
+ /// <param name="value">The value</param>
+ public virtual void Set<T>(string key, T value)
+ {
+ Set(key, value, ConfigurationLevel.Local);
+ }
+
+ /// <summary>
/// Set a configuration value for a key. Keys are in the form 'section.name'.
/// <para>
/// For example in order to set the value for this in a .git\config file:
@@ -226,7 +273,7 @@ namespace LibGit2Sharp
/// <param name="key">The key parts</param>
/// <param name="value">The value</param>
/// <param name="level">The configuration file which should be considered as the target of this operation</param>
- public virtual void Set<T>(string key, T value, ConfigurationLevel level = ConfigurationLevel.Local)
+ public virtual void Set<T>(string key, T value, ConfigurationLevel level)
{
Ensure.ArgumentNotNull(value, "value");
Ensure.ArgumentNotNullOrEmptyString(key, "key");
@@ -246,10 +293,19 @@ namespace LibGit2Sharp
/// Find configuration entries matching <paramref name="regexp"/>.
/// </summary>
/// <param name="regexp">A regular expression.</param>
+ /// <returns>Matching entries.</returns>
+ public virtual IEnumerable<ConfigurationEntry<string>> Find(string regexp)
+ {
+ return Find(regexp, ConfigurationLevel.Local);
+ }
+
+ /// <summary>
+ /// Find configuration entries matching <paramref name="regexp"/>.
+ /// </summary>
+ /// <param name="regexp">A regular expression.</param>
/// <param name="level">The configuration file into which the key should be searched for.</param>
/// <returns>Matching entries.</returns>
- public virtual IEnumerable<ConfigurationEntry<string>> Find(string regexp,
- ConfigurationLevel level = ConfigurationLevel.Local)
+ public virtual IEnumerable<ConfigurationEntry<string>> Find(string regexp, ConfigurationLevel level)
{
Ensure.ArgumentNotNullOrEmptyString(regexp, "regexp");