When no value found in the git config file, use the default one specified

This commit is contained in:
Philippe Miossec
2014-10-02 23:41:22 +02:00
parent d38051f63c
commit ebe97e7472
3 changed files with 8 additions and 7 deletions
+6 -2
View File
@@ -87,6 +87,11 @@ namespace Sep.Git.Tfs.Core
}
public T GetConfig<T>(string key)
{
return GetConfig(key, default(T));
}
public T GetConfig<T>(string key, T defaultValue)
{
try
{
@@ -95,10 +100,9 @@ namespace Sep.Git.Tfs.Core
}
catch (Exception)
{
return default(T);
return defaultValue;
}
}
public void SetConfig(string key, string value)
{
_repository.Config.Set<string>(key, value, ConfigurationLevel.Local);
+1
View File
@@ -10,6 +10,7 @@ namespace Sep.Git.Tfs.Core
string GitDir { get; set; }
string GetConfig(string key);
T GetConfig<T>(string key);
T GetConfig<T>(string key, T defaultValue);
void SetConfig(string key, string value);
IEnumerable<IGitTfsRemote> ReadAllTfsRemotes();
IGitTfsRemote ReadTfsRemote(string remoteId);
+1 -5
View File
@@ -31,11 +31,7 @@ namespace Sep.Git.Tfs.Util
if (_overrides.ContainsKey(key))
return (T) _overrides[key];
var configEntry = _globals.Repository.GetConfig<T>(key);
if (configEntry != null)
return configEntry;
return defaultValue;
return _globals.Repository.GetConfig<T>(key, defaultValue);
}
}
}