diff --git a/LibGit2Sharp/AmbiguousSpecificationException.cs b/LibGit2Sharp/AmbiguousSpecificationException.cs
index 3b9024cf8..ec6352b68 100644
--- a/LibGit2Sharp/AmbiguousSpecificationException.cs
+++ b/LibGit2Sharp/AmbiguousSpecificationException.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.Runtime.Serialization;
namespace LibGit2Sharp
@@ -25,6 +26,17 @@ public AmbiguousSpecificationException(string message)
{
}
+ ///
+ /// Initializes a new instance of the class with a specified error message.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// A composite format string for use in .
+ /// An object array that contains zero or more objects to format.
+ public AmbiguousSpecificationException(CultureInfo cultureInfo, string format, params object[] args)
+ : base(String.Format(cultureInfo, format, args))
+ {
+ }
+
///
/// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
///
diff --git a/LibGit2Sharp/BranchCollection.cs b/LibGit2Sharp/BranchCollection.cs
index 42834d042..815cdbe35 100644
--- a/LibGit2Sharp/BranchCollection.cs
+++ b/LibGit2Sharp/BranchCollection.cs
@@ -174,9 +174,9 @@ public virtual Branch Rename(Branch branch, string newName, bool allowOverwrite)
if (branch.IsRemote)
{
- throw new LibGit2SharpException(
- string.Format(CultureInfo.InvariantCulture,
- "Cannot rename branch '{0}'. It's a remote tracking branch.", branch.FriendlyName));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture,
+ "Cannot rename branch '{0}'. It's a remote tracking branch.",
+ branch.FriendlyName);
}
using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr(Reference.LocalBranchPrefix + branch.FriendlyName))
diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs
index 604587b91..5a52f0660 100644
--- a/LibGit2Sharp/Core/Proxy.cs
+++ b/LibGit2Sharp/Core/Proxy.cs
@@ -2334,8 +2334,9 @@ public static Tuple git_revparse_ext(R
return null;
case (int)GitErrorCode.Ambiguous:
- throw new AmbiguousSpecificationException(string.Format(CultureInfo.InvariantCulture,
- "Provided abbreviated ObjectId '{0}' is too short.", objectish));
+ throw new AmbiguousSpecificationException(CultureInfo.InvariantCulture,
+ "Provided abbreviated ObjectId '{0}' is too short.",
+ objectish);
default:
Ensure.ZeroResult(res);
@@ -2541,10 +2542,10 @@ public static FileStatus git_status_file(RepositorySafeHandle repo, FilePath pat
return FileStatus.Nonexistent;
case (int)GitErrorCode.Ambiguous:
- throw new AmbiguousSpecificationException(string.Format(CultureInfo.InvariantCulture,
- "More than one file matches the pathspec '{0}'. " +
- "You can either force a literal path evaluation (GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH), or use git_status_foreach().",
- path));
+ throw new AmbiguousSpecificationException(CultureInfo.InvariantCulture,
+ "More than one file matches the pathspec '{0}'. " +
+ "You can either force a literal path evaluation (GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH), or use git_status_foreach().",
+ path);
default:
Ensure.ZeroResult(res);
diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs
index 265aa0cd6..911e2425e 100644
--- a/LibGit2Sharp/Diff.cs
+++ b/LibGit2Sharp/Diff.cs
@@ -212,9 +212,11 @@ public virtual T Compare(Tree oldTree, Tree newTree, IEnumerable path
if (!ChangesBuilders.TryGetValue(typeof (T), out builder))
{
- throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture,
- "Unexpected type '{0}' passed to Compare. Supported values are either '{1}' or '{2}'.", typeof (T),
- typeof (TreeChanges), typeof (Patch)));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture,
+ "Unexpected type '{0}' passed to Compare. Supported values are either '{1}' or '{2}'.",
+ typeof(T),
+ typeof(TreeChanges),
+ typeof(Patch));
}
var comparer = TreeToTree(repo);
@@ -323,9 +325,11 @@ public virtual T Compare(Tree oldTree, DiffTargets diffTargets, IEnumerable(DiffModifiers diffOptions, IEnumerable pat
if (!ChangesBuilders.TryGetValue(typeof (T), out builder))
{
- throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture,
- "Unexpected type '{0}' passed to Compare. Supported values are either '{1}' or '{2}'.", typeof (T),
- typeof (TreeChanges), typeof (Patch)));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture,
+ "Unexpected type '{0}' passed to Compare. Supported values are either '{1}' or '{2}'.",
+ typeof(T),
+ typeof(TreeChanges),
+ typeof(Patch));
}
var comparer = WorkdirToIndex(repo);
diff --git a/LibGit2Sharp/GitObject.cs b/LibGit2Sharp/GitObject.cs
index 5e11489a2..9dbce189b 100644
--- a/LibGit2Sharp/GitObject.cs
+++ b/LibGit2Sharp/GitObject.cs
@@ -73,7 +73,10 @@ internal static GitObject BuildFrom(Repository repo, ObjectId id, GitObjectType
case GitObjectType.Blob:
return new Blob(repo, id);
default:
- throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unexpected type '{0}' for object '{1}'.", type, id));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture,
+ "Unexpected type '{0}' for object '{1}'.",
+ type,
+ id);
}
}
diff --git a/LibGit2Sharp/LibGit2SharpException.cs b/LibGit2Sharp/LibGit2SharpException.cs
index b80dba6d4..d5947b02f 100644
--- a/LibGit2Sharp/LibGit2SharpException.cs
+++ b/LibGit2Sharp/LibGit2SharpException.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.Runtime.Serialization;
using LibGit2Sharp.Core;
@@ -36,6 +37,17 @@ public LibGit2SharpException(string message, Exception innerException)
{
}
+ ///
+ /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// A composite format string for use in .
+ /// An object array that contains zero or more objects to format.
+ public LibGit2SharpException(CultureInfo cultureInfo, string format, params object[] args)
+ : base(String.Format(cultureInfo, format, args))
+ {
+ }
+
///
/// Initializes a new instance of the class with a serialized data.
///
diff --git a/LibGit2Sharp/Reference.cs b/LibGit2Sharp/Reference.cs
index 35cf7b286..61fb907c9 100644
--- a/LibGit2Sharp/Reference.cs
+++ b/LibGit2Sharp/Reference.cs
@@ -59,7 +59,7 @@ internal static T BuildFromPtr(ReferenceSafeHandle handle, Repository repo) w
break;
default:
- throw new LibGit2SharpException(String.Format(CultureInfo.InvariantCulture, "Unable to build a new reference from a type '{0}'.", type));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unable to build a new reference from a type '{0}'.", type);
}
return reference as T;
diff --git a/LibGit2Sharp/ReferenceCollectionExtensions.cs b/LibGit2Sharp/ReferenceCollectionExtensions.cs
index 5fb2f6dde..0e97ea54b 100644
--- a/LibGit2Sharp/ReferenceCollectionExtensions.cs
+++ b/LibGit2Sharp/ReferenceCollectionExtensions.cs
@@ -256,7 +256,10 @@ public static Reference UpdateTarget(this ReferenceCollection refsColl, string n
return refsColl.UpdateTarget(symbolicReference, targetRef, logMessage);
}
- throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Reference '{0}' has an unexpected type ('{1}').", name, reference.GetType()));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture,
+ "Reference '{0}' has an unexpected type ('{1}').",
+ name,
+ reference.GetType());
}
///
diff --git a/LibGit2Sharp/RemoveFromIndexException.cs b/LibGit2Sharp/RemoveFromIndexException.cs
index 57bfbafae..9f0863129 100644
--- a/LibGit2Sharp/RemoveFromIndexException.cs
+++ b/LibGit2Sharp/RemoveFromIndexException.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.Runtime.Serialization;
namespace LibGit2Sharp
@@ -25,6 +26,17 @@ public RemoveFromIndexException(string message)
{
}
+ ///
+ /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// A composite format string for use in .
+ /// An object array that contains zero or more objects to format.
+ public RemoveFromIndexException(CultureInfo cultureInfo, string format, params object[] args)
+ : base(cultureInfo, format, args)
+ {
+ }
+
///
/// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
///
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index f219e9e12..0a4007276 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -889,9 +889,7 @@ public Branch Checkout(Branch branch, CheckoutOptions options)
// Make sure this is not an unborn branch.
if (branch.Tip == null)
{
- throw new UnbornBranchException(
- string.Format(CultureInfo.InvariantCulture,
- "The tip of branch '{0}' is null. There's nothing to checkout.", branch.FriendlyName));
+ throw new UnbornBranchException(CultureInfo.InvariantCulture, "The tip of branch '{0}' is null. There's nothing to checkout.", branch.FriendlyName);
}
if (!branch.IsRemote && !(branch is DetachedHead) &&
@@ -1550,7 +1548,7 @@ private MergeResult NormalMerge(GitAnnotatedCommitHandle[] annotatedCommits, Sig
Version = 1,
MergeFileFavorFlags = options.MergeFileFavor,
MergeTreeFlags = options.FindRenames ? GitMergeTreeFlags.GIT_MERGE_TREE_FIND_RENAMES :
- GitMergeTreeFlags.GIT_MERGE_TREE_NORMAL,
+ GitMergeTreeFlags.GIT_MERGE_TREE_NORMAL,
RenameThreshold = (uint) options.RenameThreshold,
TargetLimit = (uint) options.TargetLimit,
};
@@ -1848,7 +1846,10 @@ public void Move(IEnumerable sourcePaths, IEnumerable destinatio
FileStatus sourceStatus = keyValuePair.Key.Item2;
if (sourceStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.DeletedFromIndex, FileStatus.NewInWorkdir, FileStatus.DeletedFromWorkdir }))
{
- throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unable to move file '{0}'. Its current status is '{1}'.", sourcePath, sourceStatus));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture,
+ "Unable to move file '{0}'. Its current status is '{1}'.",
+ sourcePath,
+ sourceStatus);
}
FileStatus desStatus = keyValuePair.Value.Item2;
@@ -1857,7 +1858,10 @@ public void Move(IEnumerable sourcePaths, IEnumerable destinatio
continue;
}
- throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unable to overwrite file '{0}'. Its current status is '{1}'.", destPath, desStatus));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture,
+ "Unable to overwrite file '{0}'. Its current status is '{1}'.",
+ destPath,
+ desStatus);
}
string wd = Info.WorkingDirectory;
@@ -2090,8 +2094,9 @@ private IEnumerable RemoveStagedItems(IEnumerable paths, bool re
status.HasFlag(FileStatus.ModifiedInIndex) ||
status.HasFlag(FileStatus.NewInIndex) ))
{
- throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
- treeEntryChanges.Path));
+ throw new RemoveFromIndexException(CultureInfo.InvariantCulture,
+ "Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
+ treeEntryChanges.Path);
}
removed.Add(RemoveFromIndex(treeEntryChanges.Path));
continue;
@@ -2099,20 +2104,24 @@ private IEnumerable RemoveStagedItems(IEnumerable paths, bool re
case ChangeKind.Modified:
if (status.HasFlag(FileStatus.ModifiedInWorkdir) && status.HasFlag(FileStatus.ModifiedInIndex))
{
- throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.",
- treeEntryChanges.Path));
+ throw new RemoveFromIndexException(CultureInfo.InvariantCulture,
+ "Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.",
+ treeEntryChanges.Path);
}
if (removeFromWorkingDirectory)
{
- throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
- treeEntryChanges.Path));
+ throw new RemoveFromIndexException(CultureInfo.InvariantCulture,
+ "Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.",
+ treeEntryChanges.Path);
}
removed.Add(RemoveFromIndex(treeEntryChanges.Path));
continue;
default:
- throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}'. Its current status is '{1}'.",
- treeEntryChanges.Path, treeEntryChanges.Status));
+ throw new RemoveFromIndexException(CultureInfo.InvariantCulture,
+ "Unable to remove file '{0}'. Its current status is '{1}'.",
+ treeEntryChanges.Path,
+ treeEntryChanges.Status);
}
}
@@ -2148,9 +2157,9 @@ private string DebuggerDisplay
get
{
return string.Format(CultureInfo.InvariantCulture,
- "{0} = \"{1}\"",
- Info.IsBare ? "Gitdir" : "Workdir",
- Info.IsBare ? Info.Path : Info.WorkingDirectory);
+ "{0} = \"{1}\"",
+ Info.IsBare ? "Gitdir" : "Workdir",
+ Info.IsBare ? Info.Path : Info.WorkingDirectory);
}
}
}
diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs
index 57f7b8601..385c5a9a3 100644
--- a/LibGit2Sharp/RepositoryExtensions.cs
+++ b/LibGit2Sharp/RepositoryExtensions.cs
@@ -466,7 +466,7 @@ internal static IEnumerable Committishes(this Repository repo, object
if (throwIfNotFound)
{
- throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unexpected kind of identifier '{0}'.", identifier));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unexpected kind of identifier '{0}'.", identifier);
}
yield return null;
diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs
index 14ff416a3..4c9a61fea 100644
--- a/LibGit2Sharp/SubmoduleCollection.cs
+++ b/LibGit2Sharp/SubmoduleCollection.cs
@@ -160,9 +160,7 @@ internal T Lookup(string name, Func selector, bool th
if (throwIfNotFound)
{
- throw new LibGit2SharpException(string.Format(
- CultureInfo.InvariantCulture,
- "Submodule lookup failed for '{0}'.", name));
+ throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Submodule lookup failed for '{0}'.", name);
}
return default(T);
diff --git a/LibGit2Sharp/UnbornBranchException.cs b/LibGit2Sharp/UnbornBranchException.cs
index 2704d1a93..ac2b1ee2a 100644
--- a/LibGit2Sharp/UnbornBranchException.cs
+++ b/LibGit2Sharp/UnbornBranchException.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.Runtime.Serialization;
namespace LibGit2Sharp
@@ -26,6 +27,17 @@ public UnbornBranchException(string message)
{
}
+ ///
+ /// Initializes a new instance of the class with a specified error message.
+ ///
+ /// An object that supplies culture-specific formatting information.
+ /// A composite format string for use in .
+ /// An object array that contains zero or more objects to format.
+ public UnbornBranchException(CultureInfo cultureInfo, string format, params object[] args)
+ : base(String.Format(cultureInfo, format, args))
+ {
+ }
+
///
/// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
///