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:
authornulltoken <emeric.fermas@gmail.com>2014-04-15 12:38:20 +0400
committernulltoken <emeric.fermas@gmail.com>2014-04-16 21:04:57 +0400
commitac394b41f27fe26a24b6d46a08b630abf02f72ab (patch)
tree0608304ecadaf4045dd5b7d3cde64dd683c98b3e /LibGit2Sharp
parent35ea14dd55582ba1dc4a8ad98e77ae656ee307e9 (diff)
Fix some issues pinpointed by Code Analysis
Diffstat (limited to 'LibGit2Sharp')
-rw-r--r--LibGit2Sharp/BranchUpdater.cs4
-rw-r--r--LibGit2Sharp/Configuration.cs4
-rw-r--r--LibGit2Sharp/Core/EncodingMarshaler.cs3
-rw-r--r--LibGit2Sharp/Core/Ensure.cs3
-rw-r--r--LibGit2Sharp/Core/FilePathMarshaler.cs3
-rw-r--r--LibGit2Sharp/Core/GitBlame.cs4
-rw-r--r--LibGit2Sharp/Core/GitMergeOpts.cs11
-rw-r--r--LibGit2Sharp/Core/GitObjectType.cs7
-rw-r--r--LibGit2Sharp/Core/Handles/StatusEntrySafeHandle.cs4
-rw-r--r--LibGit2Sharp/Core/HistoryRewriter.cs5
-rw-r--r--LibGit2Sharp/Core/NativeMethods.cs40
-rw-r--r--LibGit2Sharp/Core/Proxy.cs40
-rw-r--r--LibGit2Sharp/Core/TarWriter.cs19
-rw-r--r--LibGit2Sharp/Core/Utf8Marshaler.cs5
-rw-r--r--LibGit2Sharp/Diff.cs2
-rw-r--r--LibGit2Sharp/MergeOptions.cs6
-rw-r--r--LibGit2Sharp/Network.cs2
-rw-r--r--LibGit2Sharp/NetworkExtensions.cs11
-rw-r--r--LibGit2Sharp/ObjectDatabase.cs3
-rw-r--r--LibGit2Sharp/ObjectType.cs4
-rw-r--r--LibGit2Sharp/OdbBackend.cs5
-rw-r--r--LibGit2Sharp/ReferenceCollection.cs2
-rw-r--r--LibGit2Sharp/ReferenceCollectionExtensions.cs2
-rw-r--r--LibGit2Sharp/ReflogCollection.cs2
-rw-r--r--LibGit2Sharp/RemoveFromIndexException.cs5
-rw-r--r--LibGit2Sharp/RenameDetails.cs5
-rw-r--r--LibGit2Sharp/Repository.cs38
-rw-r--r--LibGit2Sharp/RepositoryExtensions.cs2
-rw-r--r--LibGit2Sharp/Signature.cs3
-rw-r--r--LibGit2Sharp/Stash.cs5
-rw-r--r--LibGit2Sharp/StashCollection.cs3
-rw-r--r--LibGit2Sharp/StatusEntry.cs5
-rw-r--r--LibGit2Sharp/TarArchiver.cs7
-rw-r--r--LibGit2Sharp/TreeEntryTargetType.cs4
-rw-r--r--LibGit2Sharp/UnmatchedPathException.cs5
35 files changed, 120 insertions, 153 deletions
diff --git a/LibGit2Sharp/BranchUpdater.cs b/LibGit2Sharp/BranchUpdater.cs
index e31a9470..83a61d34 100644
--- a/LibGit2Sharp/BranchUpdater.cs
+++ b/LibGit2Sharp/BranchUpdater.cs
@@ -125,7 +125,7 @@ namespace LibGit2Sharp
/// <param name="mergeBranchName">The merge branch in the upstream remote's namespace.</param>
private void SetUpstreamBranch(string mergeBranchName)
{
- string configKey = string.Format("branch.{0}.merge", branch.Name);
+ string configKey = string.Format(CultureInfo.InvariantCulture, "branch.{0}.merge", branch.Name);
if (string.IsNullOrEmpty(mergeBranchName))
{
@@ -143,7 +143,7 @@ namespace LibGit2Sharp
/// <param name="remoteName">The name of the remote to set as the upstream branch.</param>
private void SetUpstreamRemote(string remoteName)
{
- string configKey = string.Format("branch.{0}.remote", branch.Name);
+ string configKey = string.Format(CultureInfo.InvariantCulture, "branch.{0}.remote", branch.Name);
if (string.IsNullOrEmpty(remoteName))
{
diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs
index 43f4eb20..35678d6a 100644
--- a/LibGit2Sharp/Configuration.cs
+++ b/LibGit2Sharp/Configuration.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
-using System.Runtime.InteropServices;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Handles;
@@ -346,7 +345,8 @@ namespace LibGit2Sharp
return new Signature(
name != null ? name.Value : "unknown",
- email != null ? email.Value : string.Format("{0}@{1}", Environment.UserName, Environment.UserDomainName),
+ email != null ? email.Value : string.Format(
+ CultureInfo.InvariantCulture, "{0}@{1}", Environment.UserName, Environment.UserDomainName),
now);
}
}
diff --git a/LibGit2Sharp/Core/EncodingMarshaler.cs b/LibGit2Sharp/Core/EncodingMarshaler.cs
index 7cc87922..ad85c5ec 100644
--- a/LibGit2Sharp/Core/EncodingMarshaler.cs
+++ b/LibGit2Sharp/Core/EncodingMarshaler.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
@@ -43,7 +44,7 @@ namespace LibGit2Sharp.Core
if (str == null)
{
throw new MarshalDirectiveException(
- string.Format("{0} must be used on a string.", GetType().Name));
+ string.Format(CultureInfo.InvariantCulture, "{0} must be used on a string.", GetType().Name));
}
return FromManaged(encoding, str);
diff --git a/LibGit2Sharp/Core/Ensure.cs b/LibGit2Sharp/Core/Ensure.cs
index 368ffe9e..df928202 100644
--- a/LibGit2Sharp/Core/Ensure.cs
+++ b/LibGit2Sharp/Core/Ensure.cs
@@ -67,7 +67,8 @@ namespace LibGit2Sharp.Core
}
throw new ArgumentException(
- string.Format("Zero bytes ('\\0') are not allowed. A zero byte has been found at position {0}.", zeroPos), argumentName);
+ string.Format(CultureInfo.InvariantCulture,
+ "Zero bytes ('\\0') are not allowed. A zero byte has been found at position {0}.", zeroPos), argumentName);
}
private static readonly Dictionary<GitErrorCode, Func<string, GitErrorCode, GitErrorCategory, LibGit2SharpException>>
diff --git a/LibGit2Sharp/Core/FilePathMarshaler.cs b/LibGit2Sharp/Core/FilePathMarshaler.cs
index 9c5df4b2..6b17df4c 100644
--- a/LibGit2Sharp/Core/FilePathMarshaler.cs
+++ b/LibGit2Sharp/Core/FilePathMarshaler.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
@@ -69,7 +70,7 @@ namespace LibGit2Sharp.Core
if (null == filePath)
{
throw new MarshalDirectiveException(
- string.Format("{0} must be used on a FilePath.", GetType().Name));
+ string.Format(CultureInfo.InvariantCulture, "{0} must be used on a FilePath.", GetType().Name));
}
return FromManaged(filePath);
diff --git a/LibGit2Sharp/Core/GitBlame.cs b/LibGit2Sharp/Core/GitBlame.cs
index 21193daa..0c24aefc 100644
--- a/LibGit2Sharp/Core/GitBlame.cs
+++ b/LibGit2Sharp/Core/GitBlame.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.Runtime.InteropServices;
namespace LibGit2Sharp.Core
@@ -78,7 +79,8 @@ namespace LibGit2Sharp.Core
return GitBlameOptionFlags.GIT_BLAME_NORMAL;
default:
- throw new NotSupportedException(string.Format("{0} is not supported at this time", strategy));
+ throw new NotSupportedException(
+ string.Format(CultureInfo.InvariantCulture, "{0} is not supported at this time", strategy));
}
}
}
diff --git a/LibGit2Sharp/Core/GitMergeOpts.cs b/LibGit2Sharp/Core/GitMergeOpts.cs
index 0f5cf445..36ccd45f 100644
--- a/LibGit2Sharp/Core/GitMergeOpts.cs
+++ b/LibGit2Sharp/Core/GitMergeOpts.cs
@@ -33,9 +33,10 @@ namespace LibGit2Sharp.Core
public GitMergeFileFavorFlags MergeFileFavorFlags;
}
- /// <summary>
- /// The results of `git_merge_analysis` indicate the merge opportunities.
- /// </summary>
+ /// <summary>
+ /// The results of `git_merge_analysis` indicate the merge opportunities.
+ /// </summary>
+ [Flags]
internal enum GitMergeAnalysis
{
/// <summary>
@@ -44,8 +45,8 @@ namespace LibGit2Sharp.Core
GIT_MERGE_ANALYSIS_NONE = 0,
/// <summary>
- /// A "normal" merge; both HEAD and the given merge input have diverged
- /// from their common ancestor. The divergent commits must be merged.
+ /// A "normal" merge; both HEAD and the given merge input have diverged
+ /// from their common ancestor. The divergent commits must be merged.
/// </summary>
GIT_MERGE_ANALYSIS_NORMAL = (1 << 0),
diff --git a/LibGit2Sharp/Core/GitObjectType.cs b/LibGit2Sharp/Core/GitObjectType.cs
index a099c480..a38523f2 100644
--- a/LibGit2Sharp/Core/GitObjectType.cs
+++ b/LibGit2Sharp/Core/GitObjectType.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
namespace LibGit2Sharp.Core
{
@@ -74,7 +75,8 @@ namespace LibGit2Sharp.Core
return TreeEntryTargetType.Blob;
default:
- throw new InvalidOperationException(string.Format("Cannot map {0} to a TreeEntryTargetType.", type));
+ throw new InvalidOperationException(
+ string.Format(CultureInfo.InvariantCulture, "Cannot map {0} to a TreeEntryTargetType.", type));
}
}
@@ -95,7 +97,8 @@ namespace LibGit2Sharp.Core
return ObjectType.Tag;
default:
- throw new InvalidOperationException(string.Format("Cannot map {0} to a ObjectType.", type));
+ throw new InvalidOperationException(
+ string.Format(CultureInfo.InvariantCulture, "Cannot map {0} to a ObjectType.", type));
}
}
}
diff --git a/LibGit2Sharp/Core/Handles/StatusEntrySafeHandle.cs b/LibGit2Sharp/Core/Handles/StatusEntrySafeHandle.cs
index 0a85125f..45b6eacd 100644
--- a/LibGit2Sharp/Core/Handles/StatusEntrySafeHandle.cs
+++ b/LibGit2Sharp/Core/Handles/StatusEntrySafeHandle.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
namespace LibGit2Sharp.Core.Handles
{
diff --git a/LibGit2Sharp/Core/HistoryRewriter.cs b/LibGit2Sharp/Core/HistoryRewriter.cs
index 1e61fc1f..77ca3546 100644
--- a/LibGit2Sharp/Core/HistoryRewriter.cs
+++ b/LibGit2Sharp/Core/HistoryRewriter.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Globalization;
using System.Linq;
namespace LibGit2Sharp.Core
@@ -157,7 +158,9 @@ namespace LibGit2Sharp.Core
if (repo.Refs.Resolve<Reference>(backupName) != null)
{
throw new InvalidOperationException(
- String.Format("Can't back up reference '{0}' - '{1}' already exists", oldRef.CanonicalName, backupName));
+ String.Format(
+ CultureInfo.InvariantCulture, "Can't back up reference '{0}' - '{1}' already exists",
+ oldRef.CanonicalName, backupName));
}
repo.Refs.Add(backupName, oldRef.TargetIdentifier, signature, "filter-branch: backup");
diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs
index 84dbee9b..97ecd4aa 100644
--- a/LibGit2Sharp/Core/NativeMethods.cs
+++ b/LibGit2Sharp/Core/NativeMethods.cs
@@ -122,7 +122,7 @@ namespace LibGit2Sharp.Core
GitBlameOptions options);
[DllImport(libgit2)]
- internal static extern int git_blame_free(IntPtr blame);
+ internal static extern void git_blame_free(IntPtr blame);
[DllImport(libgit2)]
internal static extern int git_blob_create_fromdisk(
@@ -306,7 +306,7 @@ namespace LibGit2Sharp.Core
ConfigurationSafeHandle cfg,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath path,
uint level,
- bool force);
+ [MarshalAs(UnmanagedType.Bool)] bool force);
[DllImport(libgit2)]
internal static extern int git_config_new(out ConfigurationSafeHandle cfg);
@@ -456,13 +456,6 @@ namespace LibGit2Sharp.Core
IntPtr payload);
[DllImport(libgit2)]
- internal static extern int git_diff_print(
- DiffSafeHandle diff,
- GitDiffFormat format,
- git_diff_line_cb printCallback,
- IntPtr payload);
-
- [DllImport(libgit2)]
internal static extern int git_diff_blobs(
GitObjectSafeHandle oldBlob,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath old_as_path,
@@ -541,12 +534,6 @@ namespace LibGit2Sharp.Core
internal static extern int git_index_entry_stage(IndexEntrySafeHandle indexentry);
[DllImport(libgit2)]
- internal static extern int git_index_find(
- out UIntPtr pos,
- IndexSafeHandle index,
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath path);
-
- [DllImport(libgit2)]
internal static extern void git_index_free(IntPtr index);
[DllImport(libgit2)]
@@ -567,7 +554,9 @@ namespace LibGit2Sharp.Core
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath indexpath);
[DllImport(libgit2)]
- internal static extern int git_index_read(IndexSafeHandle index, bool force);
+ internal static extern int git_index_read(
+ IndexSafeHandle index,
+ [MarshalAs(UnmanagedType.Bool)] bool force);
[DllImport(libgit2)]
internal static extern int git_index_remove_bypath(
@@ -641,7 +630,7 @@ namespace LibGit2Sharp.Core
internal static extern int git_message_prettify(
GitBuf buf,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string message,
- bool strip_comments);
+ [MarshalAs(UnmanagedType.Bool)] bool strip_comments);
[DllImport(libgit2)]
internal static extern int git_note_create(
@@ -926,16 +915,6 @@ namespace LibGit2Sharp.Core
SafeHandle entry);
[DllImport(libgit2)]
- internal static extern int git_reflog_append(
- ReflogSafeHandle reflog,
- ref GitOid id,
- SignatureSafeHandle committer,
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string msg);
-
- [DllImport(libgit2)]
- internal static extern int git_reflog_write(ReflogSafeHandle reflog);
-
- [DllImport(libgit2)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))]
internal static extern string git_reflog_entry_message(SafeHandle entry);
@@ -1105,9 +1084,6 @@ namespace LibGit2Sharp.Core
internal static extern int git_repository_is_bare(RepositorySafeHandle handle);
[DllImport(libgit2)]
- internal static extern int git_repository_is_empty(RepositorySafeHandle repo);
-
- [DllImport(libgit2)]
internal static extern int git_repository_is_shallow(RepositorySafeHandle repo);
[DllImport(libgit2)]
@@ -1161,7 +1137,7 @@ namespace LibGit2Sharp.Core
internal static extern int git_repository_set_workdir(
RepositorySafeHandle repository,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath workdir,
- bool update_gitlink);
+ [MarshalAs(UnmanagedType.Bool)] bool update_gitlink);
[DllImport(libgit2)]
internal static extern int git_repository_set_head_detached(
@@ -1307,7 +1283,7 @@ namespace LibGit2Sharp.Core
[DllImport(libgit2)]
internal static extern int git_submodule_add_to_index(
SubmoduleSafeHandle submodule,
- bool write_index);
+ [MarshalAs(UnmanagedType.Bool)] bool write_index);
[DllImport(libgit2)]
internal static extern int git_submodule_save(
diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs
index e8a68245..b91e9fa1 100644
--- a/LibGit2Sharp/Core/Proxy.cs
+++ b/LibGit2Sharp/Core/Proxy.cs
@@ -114,16 +114,6 @@ namespace LibGit2Sharp.Core
new[] { buf });
}
- public static byte[] git_blob_rawcontent(RepositorySafeHandle repo, ObjectId id, int size)
- {
- using (var obj = new ObjectSafeWrapper(id, repo))
- {
- var arr = new byte[size];
- Marshal.Copy(NativeMethods.git_blob_rawcontent(obj.ObjectPtr), arr, 0, size);
- return arr;
- }
- }
-
public static UnmanagedMemoryStream git_blob_rawcontent_stream(RepositorySafeHandle repo, ObjectId id, Int64 size)
{
var handle = new ObjectSafeWrapper(id, repo).ObjectPtr;
@@ -649,16 +639,6 @@ namespace LibGit2Sharp.Core
}
}
- public static void git_diff_print(DiffSafeHandle diff, NativeMethods.git_diff_line_cb printCallback)
- {
- using (ThreadAffinity())
- {
- int res = NativeMethods.git_diff_print(diff, GitDiffFormat.GIT_DIFF_FORMAT_PATCH,
- printCallback, IntPtr.Zero);
- Ensure.ZeroResult(res);
- }
- }
-
public static DiffSafeHandle git_diff_tree_to_tree(
RepositorySafeHandle repo,
ObjectId oldTree,
@@ -1648,21 +1628,6 @@ namespace LibGit2Sharp.Core
return NativeMethods.git_reflog_entry_message(entry);
}
- public static void git_reflog_append(ReflogSafeHandle reflog, ObjectId commit_id, Signature committer, string message)
- {
- using (ThreadAffinity())
- using (SignatureSafeHandle sigHandle = committer.BuildHandle())
- {
- var oid = commit_id.Oid;
-
- int res = NativeMethods.git_reflog_append(reflog, ref oid, sigHandle, message);
- Ensure.ZeroResult(res);
-
- res = NativeMethods.git_reflog_write(reflog);
- Ensure.ZeroResult(res);
- }
- }
-
#endregion
#region git_refspec
@@ -2005,11 +1970,6 @@ namespace LibGit2Sharp.Core
return RepositoryStateChecker(repo, NativeMethods.git_repository_is_bare);
}
- public static bool git_repository_is_empty(RepositorySafeHandle repo)
- {
- return RepositoryStateChecker(repo, NativeMethods.git_repository_is_empty);
- }
-
public static bool git_repository_is_shallow(RepositorySafeHandle repo)
{
return RepositoryStateChecker(repo, NativeMethods.git_repository_is_shallow);
diff --git a/LibGit2Sharp/Core/TarWriter.cs b/LibGit2Sharp/Core/TarWriter.cs
index f86f56a1..54037274 100644
--- a/LibGit2Sharp/Core/TarWriter.cs
+++ b/LibGit2Sharp/Core/TarWriter.cs
@@ -16,6 +16,7 @@
*/
using System;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
@@ -85,7 +86,7 @@ namespace LibGit2Sharp.Core
AlignTo512((data != null) ? data.Length : 0, false);
}
- protected void WriteContent(long count, Stream data, Stream dest)
+ protected static void WriteContent(long count, Stream data, Stream dest)
{
var buffer = new byte[1024];
@@ -148,7 +149,7 @@ namespace LibGit2Sharp.Core
OutStream.Write(header, 0, header.Length);
}
- private LinkExtendedHeader ParseLink(bool isLink, Stream data, string entrySha)
+ private static LinkExtendedHeader ParseLink(bool isLink, Stream data, string entrySha)
{
if (!isLink)
{
@@ -166,7 +167,8 @@ namespace LibGit2Sharp.Core
if (data.Length > 100)
{
- return new LinkExtendedHeader(link, string.Format("see %s.paxheader{0}", entrySha), true);
+ return new LinkExtendedHeader(link,
+ string.Format(CultureInfo.InvariantCulture, "see %s.paxheader{0}", entrySha), true);
}
return new LinkExtendedHeader(link, link, false);
@@ -196,19 +198,19 @@ namespace LibGit2Sharp.Core
using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(extHeader)))
{
- Write(string.Format("{0}.paxheader", entrySha), stream, modificationTime, "666".OctalToInt32(),
+ Write(string.Format(CultureInfo.InvariantCulture, "{0}.paxheader", entrySha), stream, modificationTime, "666".OctalToInt32(),
"0", "0", 'x', "root", "root", "0", "0", entrySha, false);
}
}
- private string BuildKeyValueExtHeader(string key, string value)
+ private static string BuildKeyValueExtHeader(string key, string value)
{
// "%u %s=%s\n"
int len = key.Length + value.Length + 3;
for (int i = len; i > 9; i /= 10)
len++;
- return string.Format("{0} {1}={2}\n", len, key, value);
+ return string.Format(CultureInfo.InvariantCulture, "{0} {1}={2}\n", len, key, value);
}
/// <summary>
@@ -331,7 +333,7 @@ namespace LibGit2Sharp.Core
return buffer;
}
- private string CalculateChecksum(byte[] buf)
+ private static string CalculateChecksum(byte[] buf)
{
Encoding.ASCII.GetBytes(new string(' ', 8)).CopyTo(buf, 148);
@@ -408,7 +410,8 @@ namespace LibGit2Sharp.Core
return new FileNameExtendedHeader(posixPath, posixPath.Substring(0, position), posixPath.Substring(position, posixPath.Length - position), false);
}
- return new FileNameExtendedHeader(posixPath, string.Empty, string.Format("{0}.data", entrySha), true);
+ return new FileNameExtendedHeader(posixPath, string.Empty,
+ string.Format(CultureInfo.InvariantCulture, "{0}.data", entrySha), true);
}
return new FileNameExtendedHeader(posixPath, string.Empty, posixPath, false);
diff --git a/LibGit2Sharp/Core/Utf8Marshaler.cs b/LibGit2Sharp/Core/Utf8Marshaler.cs
index 8a480816..c623fe99 100644
--- a/LibGit2Sharp/Core/Utf8Marshaler.cs
+++ b/LibGit2Sharp/Core/Utf8Marshaler.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
@@ -70,7 +71,7 @@ namespace LibGit2Sharp.Core
public override Object MarshalNativeToManaged(IntPtr pNativeData)
{
throw new InvalidOperationException(
- string.Format("{0} cannot be used to retrieve data from libgit2.", GetType().Name));
+ string.Format(CultureInfo.InvariantCulture, "{0} cannot be used to retrieve data from libgit2.", GetType().Name));
}
#endregion
@@ -105,7 +106,7 @@ namespace LibGit2Sharp.Core
public override IntPtr MarshalManagedToNative(object managedObj)
{
throw new InvalidOperationException(
- string.Format("{0} cannot be used to pass data to libgit2.", GetType().Name));
+ string.Format(CultureInfo.InvariantCulture, "{0} cannot be used to pass data to libgit2.", GetType().Name));
}
#endregion
diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs
index bde61d7e..c888d7a6 100644
--- a/LibGit2Sharp/Diff.cs
+++ b/LibGit2Sharp/Diff.cs
@@ -352,7 +352,7 @@ namespace LibGit2Sharp
}
}
- private void DetectRenames(DiffSafeHandle diffList, CompareOptions compareOptions)
+ private static void DetectRenames(DiffSafeHandle diffList, CompareOptions compareOptions)
{
var similarityOptions = (compareOptions == null) ? null : compareOptions.Similarity;
if (similarityOptions == null ||
diff --git a/LibGit2Sharp/MergeOptions.cs b/LibGit2Sharp/MergeOptions.cs
index 49096dbd..06eb13ce 100644
--- a/LibGit2Sharp/MergeOptions.cs
+++ b/LibGit2Sharp/MergeOptions.cs
@@ -4,7 +4,7 @@ namespace LibGit2Sharp
/// <summary>
/// Options controlling Merge behavior.
/// </summary>
- public class MergeOptions
+ public sealed class MergeOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="MergeOptions"/> class.
@@ -21,12 +21,12 @@ namespace LibGit2Sharp
/// If this is a fast-forward merge, then there is no merge commit and this option
/// will not affect the merge.
/// </summary>
- public virtual bool CommitOnSuccess { get; set; }
+ public bool CommitOnSuccess { get; set; }
/// <summary>
/// The type of merge to perform.
/// </summary>
- public virtual FastForwardStrategy FastForwardStrategy { get; set; }
+ public FastForwardStrategy FastForwardStrategy { get; set; }
}
/// <summary>
diff --git a/LibGit2Sharp/Network.cs b/LibGit2Sharp/Network.cs
index f982d0d9..6fffc231 100644
--- a/LibGit2Sharp/Network.cs
+++ b/LibGit2Sharp/Network.cs
@@ -220,7 +220,7 @@ namespace LibGit2Sharp
Ensure.ArgumentNotNull(remote, "remote");
Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, "pushRefSpec");
- Push(remote, new string[] { pushRefSpec }, pushOptions, signature, logMessage);
+ Push(remote, new[] { pushRefSpec }, pushOptions, signature, logMessage);
}
/// <summary>
diff --git a/LibGit2Sharp/NetworkExtensions.cs b/LibGit2Sharp/NetworkExtensions.cs
index 6016aafa..d8b139c4 100644
--- a/LibGit2Sharp/NetworkExtensions.cs
+++ b/LibGit2Sharp/NetworkExtensions.cs
@@ -44,14 +44,19 @@ namespace LibGit2Sharp
{
if (string.IsNullOrEmpty(branch.UpstreamBranchCanonicalName))
{
- throw new LibGit2SharpException(string.Format("The branch '{0}' (\"{1}\") that you are trying to push does not track an upstream branch.",
- branch.Name, branch.CanonicalName));
+ throw new LibGit2SharpException(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "The branch '{0}' (\"{1}\") that you are trying to push does not track an upstream branch.",
+ branch.Name, branch.CanonicalName));
}
}
foreach (var branch in enumeratedBranches)
{
- network.Push(branch.Remote, string.Format("{0}:{1}", branch.CanonicalName, branch.UpstreamBranchCanonicalName), pushOptions);
+ network.Push(branch.Remote, string.Format(
+ CultureInfo.InvariantCulture,
+ "{0}:{1}", branch.CanonicalName, branch.UpstreamBranchCanonicalName), pushOptions);
}
}
}
diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs
index 8f3e19ae..f40ec4e8 100644
--- a/LibGit2Sharp/ObjectDatabase.cs
+++ b/LibGit2Sharp/ObjectDatabase.cs
@@ -7,7 +7,6 @@ using System.Linq;
using System.Runtime.InteropServices;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Handles;
-using LibGit2Sharp.Handlers;
namespace LibGit2Sharp
{
@@ -108,7 +107,7 @@ namespace LibGit2Sharp
Ensure.ArgumentNotNull(backend, "backend");
Ensure.ArgumentConformsTo(priority, s => s > 0, "priority");
- Proxy.git_odb_add_backend(this.handle, backend.GitOdbBackendPointer, priority);
+ Proxy.git_odb_add_backend(handle, backend.GitOdbBackendPointer, priority);
}
private class Processor
diff --git a/LibGit2Sharp/ObjectType.cs b/LibGit2Sharp/ObjectType.cs
index 9b4e007d..3e5d415f 100644
--- a/LibGit2Sharp/ObjectType.cs
+++ b/LibGit2Sharp/ObjectType.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
@@ -48,7 +49,8 @@ namespace LibGit2Sharp
return GitObjectType.Tag;
default:
- throw new InvalidOperationException(string.Format("Cannot map {0} to a GitObjectType.", type));
+ throw new InvalidOperationException(
+ string.Format(CultureInfo.InvariantCulture, "Cannot map {0} to a GitObjectType.", type));
}
}
}
diff --git a/LibGit2Sharp/OdbBackend.cs b/LibGit2Sharp/OdbBackend.cs
index 1862d26b..54994253 100644
--- a/LibGit2Sharp/OdbBackend.cs
+++ b/LibGit2Sharp/OdbBackend.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using LibGit2Sharp.Core;
@@ -569,7 +570,9 @@ namespace LibGit2Sharp
if (len.ToUInt64() > long.MaxValue)
{
throw new InvalidOperationException(
- string.Format("Provided length ({0}) exceeds long.MaxValue ({1}).",
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "Provided length ({0}) exceeds long.MaxValue ({1}).",
len.ToUInt64(), long.MaxValue));
}
diff --git a/LibGit2Sharp/ReferenceCollection.cs b/LibGit2Sharp/ReferenceCollection.cs
index 6ec43162..7fc64667 100644
--- a/LibGit2Sharp/ReferenceCollection.cs
+++ b/LibGit2Sharp/ReferenceCollection.cs
@@ -158,7 +158,7 @@ namespace LibGit2Sharp
if (logMessage == null)
{
- logMessage = string.Format("{0}: renamed {1} to {2}",
+ logMessage = string.Format(CultureInfo.InvariantCulture, "{0}: renamed {1} to {2}",
reference.IsLocalBranch() ? "branch" : "reference", reference.CanonicalName, newName);
}
diff --git a/LibGit2Sharp/ReferenceCollectionExtensions.cs b/LibGit2Sharp/ReferenceCollectionExtensions.cs
index c0e65d6c..6be57a77 100644
--- a/LibGit2Sharp/ReferenceCollectionExtensions.cs
+++ b/LibGit2Sharp/ReferenceCollectionExtensions.cs
@@ -70,7 +70,7 @@ namespace LibGit2Sharp
if (logMessage == null)
{
- logMessage = string.Format("{0}: Created from {1}",
+ logMessage = string.Format(CultureInfo.InvariantCulture, "{0}: Created from {1}",
name.LooksLikeLocalBranch() ? "branch" : "reference", canonicalRefNameOrObjectish);
}
diff --git a/LibGit2Sharp/ReflogCollection.cs b/LibGit2Sharp/ReflogCollection.cs
index 3d6fa660..35d9fbd7 100644
--- a/LibGit2Sharp/ReflogCollection.cs
+++ b/LibGit2Sharp/ReflogCollection.cs
@@ -39,7 +39,7 @@ namespace LibGit2Sharp
if (!repo.Refs.IsValidName(canonicalName))
{
throw new InvalidSpecificationException(
- string.Format("The given reference name '{0}' is not valid", canonicalName));
+ string.Format(CultureInfo.InvariantCulture, "The given reference name '{0}' is not valid", canonicalName));
}
this.repo = repo;
diff --git a/LibGit2Sharp/RemoveFromIndexException.cs b/LibGit2Sharp/RemoveFromIndexException.cs
index 7e138120..52e9ffc7 100644
--- a/LibGit2Sharp/RemoveFromIndexException.cs
+++ b/LibGit2Sharp/RemoveFromIndexException.cs
@@ -45,10 +45,5 @@ namespace LibGit2Sharp
: base(info, context)
{
}
-
- internal RemoveFromIndexException(string message, GitErrorCode code, GitErrorCategory category)
- : base(message, code, category)
- {
- }
}
}
diff --git a/LibGit2Sharp/RenameDetails.cs b/LibGit2Sharp/RenameDetails.cs
index bfc47058..199b7269 100644
--- a/LibGit2Sharp/RenameDetails.cs
+++ b/LibGit2Sharp/RenameDetails.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Globalization;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
@@ -109,7 +110,9 @@ namespace LibGit2Sharp
{
get
{
- return string.Format("{0} -> {1} [{2}%]", OldFilePath, NewFilePath, Similarity);
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} -> {1} [{2}%]", OldFilePath, NewFilePath, Similarity);
}
}
}
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index 3a9bbbef..a05d13c5 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -341,7 +341,6 @@ namespace LibGit2Sharp
public void Dispose()
{
Dispose(true);
- GC.SuppressFinalize(this);
}
/// <summary>
@@ -733,7 +732,9 @@ namespace LibGit2Sharp
CheckoutTree(tree, null, opts);
Refs.UpdateTarget("HEAD", headTarget, signature,
- string.Format("checkout: moving from {0} to {1}", previousHeadName, refLogHeadSpec));
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "checkout: moving from {0} to {1}", previousHeadName, refLogHeadSpec));
}
/// <summary>
@@ -792,7 +793,9 @@ namespace LibGit2Sharp
if (logMessage == null)
{
- logMessage = string.Format("reset: moving to {0}", commit.Sha);
+ logMessage = string.Format(
+ CultureInfo.InvariantCulture,
+ "reset: moving to {0}", commit.Sha);
}
Proxy.git_reset(handle, commit.Id, resetMode, signature.OrDefault(Config), logMessage);
@@ -882,7 +885,8 @@ namespace LibGit2Sharp
{
throw new EmptyCommitException(
options.AmendPreviousCommit ?
- String.Format("Amending this commit would produce a commit that is identical to its parent (id = {0})", parents[0].Id) :
+ String.Format(CultureInfo.InvariantCulture,
+ "Amending this commit would produce a commit that is identical to its parent (id = {0})", parents[0].Id) :
"No changes; nothing to commit.");
}
}
@@ -903,7 +907,7 @@ namespace LibGit2Sharp
return result;
}
- private string BuildCommitLogMessage(Commit commit, bool amendPreviousCommit, bool isHeadOrphaned, bool isMergeCommit)
+ private static string BuildCommitLogMessage(Commit commit, bool amendPreviousCommit, bool isHeadOrphaned, bool isMergeCommit)
{
string kind = string.Empty;
if (isHeadOrphaned)
@@ -919,7 +923,7 @@ namespace LibGit2Sharp
kind = " (merge)";
}
- return string.Format("commit{0}: {1}", kind, commit.MessageShort);
+ return string.Format(CultureInfo.InvariantCulture, "commit{0}: {1}", kind, commit.MessageShort);
}
private void LogCommit(Commit commit, string reflogMessage)
@@ -1060,7 +1064,7 @@ namespace LibGit2Sharp
using (GitMergeHeadHandle mergeHeadHandle = Proxy.git_merge_head_from_id(Handle, commit.Id.Oid))
{
- return Merge(new GitMergeHeadHandle[] { mergeHeadHandle }, merger, options);
+ return Merge(new[] { mergeHeadHandle }, merger, options);
}
}
@@ -1081,7 +1085,7 @@ namespace LibGit2Sharp
using (ReferenceSafeHandle referencePtr = Refs.RetrieveReferencePtr(branch.CanonicalName))
using (GitMergeHeadHandle mergeHeadHandle = Proxy.git_merge_head_from_ref(Handle, referencePtr))
{
- return Merge(new GitMergeHeadHandle[] { mergeHeadHandle }, merger, options);
+ return Merge(new[] { mergeHeadHandle }, merger, options);
}
}
@@ -1099,7 +1103,7 @@ namespace LibGit2Sharp
options = options ?? new MergeOptions();
- Commit commit = this.LookupCommit(committish);
+ Commit commit = LookupCommit(committish);
return Merge(commit, merger, options);
}
@@ -1202,12 +1206,14 @@ namespace LibGit2Sharp
}
break;
default:
- throw new NotImplementedException(string.Format("Unknown fast forward strategy: {0}", mergeAnalysis));
+ throw new NotImplementedException(
+ string.Format(CultureInfo.InvariantCulture, "Unknown fast forward strategy: {0}", mergeAnalysis));
}
if (mergeResult == null)
{
- throw new NotImplementedException(string.Format("Unknown merge analysis: {0}", options.FastForwardStrategy));
+ throw new NotImplementedException(
+ string.Format(CultureInfo.InvariantCulture, "Unknown merge analysis: {0}", options.FastForwardStrategy));
}
return mergeResult;
@@ -1224,12 +1230,12 @@ namespace LibGit2Sharp
{
MergeResult mergeResult;
- GitMergeOpts mergeOptions = new GitMergeOpts()
+ var mergeOptions = new GitMergeOpts
{
Version = 1
};
- GitCheckoutOpts checkoutOpts = new GitCheckoutOpts()
+ var checkoutOpts = new GitCheckoutOpts
{
version = 1
};
@@ -1242,7 +1248,7 @@ namespace LibGit2Sharp
if (options.CommitOnSuccess)
{
// Commit the merge
- mergeCommit = this.Commit(Info.Message, author: merger, committer: merger);
+ mergeCommit = Commit(Info.Message, author: merger, committer: merger);
}
mergeResult = new MergeResult(MergeStatus.NonFastForward, mergeCommit);
@@ -1276,7 +1282,9 @@ namespace LibGit2Sharp
var reference = Refs.Head.ResolveToDirectReference();
// TODO: This reflog entry could be more specific
- string refLogEntry = string.Format("merge {0}: Fast-forward", fastForwardCommit.Sha);
+ string refLogEntry = string.Format(
+ CultureInfo.InvariantCulture, "merge {0}: Fast-forward", fastForwardCommit.Sha);
+
if (reference == null)
{
// Reference does not exist, create it.
diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs
index 9f31d71e..8e859072 100644
--- a/LibGit2Sharp/RepositoryExtensions.cs
+++ b/LibGit2Sharp/RepositoryExtensions.cs
@@ -5,7 +5,6 @@ using System.Globalization;
using System.IO;
using System.Linq;
using LibGit2Sharp.Core;
-using LibGit2Sharp.Handlers;
namespace LibGit2Sharp
{
@@ -414,6 +413,7 @@ namespace LibGit2Sharp
{
throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unexpected kind of identifier '{0}'.", identifier));
}
+
yield return null;
}
diff --git a/LibGit2Sharp/Signature.cs b/LibGit2Sharp/Signature.cs
index bc9dc778..74be2644 100644
--- a/LibGit2Sharp/Signature.cs
+++ b/LibGit2Sharp/Signature.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.Runtime.InteropServices;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Handles;
@@ -130,7 +131,7 @@ namespace LibGit2Sharp
/// <returns>The <see cref="Name"/> and <see cref="Email"/> of the current <see cref="Signature"/>.</returns>
public override string ToString()
{
- return string.Format("{0} <{1}>", Name, Email);
+ return string.Format(CultureInfo.InvariantCulture, "{0} <{1}>", Name, Email);
}
}
}
diff --git a/LibGit2Sharp/Stash.cs b/LibGit2Sharp/Stash.cs
index b8ba98a0..07bd6559 100644
--- a/LibGit2Sharp/Stash.cs
+++ b/LibGit2Sharp/Stash.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System.Globalization;
+using System.Linq;
namespace LibGit2Sharp
{
@@ -15,7 +16,7 @@ namespace LibGit2Sharp
{ }
internal Stash(Repository repo, ObjectId targetId, int index)
- : base(repo, new DirectReference(string.Format("stash@{{{0}}}", index), repo, targetId), r => r.CanonicalName)
+ : base(repo, new DirectReference(string.Format(CultureInfo.InvariantCulture, "stash@{{{0}}}", index), repo, targetId), r => r.CanonicalName)
{ }
/// <summary>
diff --git a/LibGit2Sharp/StashCollection.cs b/LibGit2Sharp/StashCollection.cs
index e0bd7d24..07fc3379 100644
--- a/LibGit2Sharp/StashCollection.cs
+++ b/LibGit2Sharp/StashCollection.cs
@@ -69,7 +69,8 @@ namespace LibGit2Sharp
throw new ArgumentOutOfRangeException("index", "The passed index must be a positive integer.");
}
- GitObject stashCommit = repo.Lookup(string.Format("stash@{{{0}}}", index), GitObjectType.Commit, LookUpOptions.None);
+ GitObject stashCommit = repo.Lookup(
+ string.Format(CultureInfo.InvariantCulture, "stash@{{{0}}}", index), GitObjectType.Commit, LookUpOptions.None);
return stashCommit == null ? null : new Stash(repo, stashCommit.Id, index);
}
diff --git a/LibGit2Sharp/StatusEntry.cs b/LibGit2Sharp/StatusEntry.cs
index a049d316..ecf56dbe 100644
--- a/LibGit2Sharp/StatusEntry.cs
+++ b/LibGit2Sharp/StatusEntry.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Globalization;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
@@ -125,10 +126,10 @@ namespace LibGit2Sharp
string oldFilePath = ((State & FileStatus.RenamedInIndex) == FileStatus.RenamedInIndex) ?
HeadToIndexRenameDetails.OldFilePath : IndexToWorkDirRenameDetails.OldFilePath;
- return string.Format("{0}: {1} -> {2}", State, oldFilePath, FilePath);
+ return string.Format(CultureInfo.InvariantCulture, "{0}: {1} -> {2}", State, oldFilePath, FilePath);
}
- return string.Format("{0}: {1}", State, FilePath);
+ return string.Format(CultureInfo.InvariantCulture, "{0}: {1}", State, FilePath);
}
}
}
diff --git a/LibGit2Sharp/TarArchiver.cs b/LibGit2Sharp/TarArchiver.cs
index f6fe7520..de5bf046 100644
--- a/LibGit2Sharp/TarArchiver.cs
+++ b/LibGit2Sharp/TarArchiver.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.IO;
using System.Text;
using LibGit2Sharp.Core;
@@ -28,7 +29,8 @@ namespace LibGit2Sharp
}
// Store the sha in the pax_global_header
- using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(string.Format("52 comment={0}\n", oid.Sha))))
+ using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(
+ string.Format(CultureInfo.InvariantCulture, "52 comment={0}\n", oid.Sha))))
{
writer.Write("pax_global_header", stream, modificationTime, "666".OctalToInt32(),
"0", "0", 'g', "root", "root", "0", "0", oid.Sha, false);
@@ -60,7 +62,8 @@ namespace LibGit2Sharp
}
break;
default:
- throw new InvalidOperationException(string.Format("Unsupported file mode: {0} (sha1: {1}).", entry.Mode, entry.TargetId.Sha));
+ throw new InvalidOperationException(
+ string.Format(CultureInfo.InvariantCulture, "Unsupported file mode: {0} (sha1: {1}).", entry.Mode, entry.TargetId.Sha));
}
}
diff --git a/LibGit2Sharp/TreeEntryTargetType.cs b/LibGit2Sharp/TreeEntryTargetType.cs
index 0dfca339..a4e54d73 100644
--- a/LibGit2Sharp/TreeEntryTargetType.cs
+++ b/LibGit2Sharp/TreeEntryTargetType.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
@@ -37,7 +38,8 @@ namespace LibGit2Sharp
return GitObjectType.Blob;
default:
- throw new InvalidOperationException(string.Format("Cannot map {0} to a GitObjectType.", type));
+ throw new InvalidOperationException(
+ string.Format(CultureInfo.InvariantCulture, "Cannot map {0} to a GitObjectType.", type));
}
}
}
diff --git a/LibGit2Sharp/UnmatchedPathException.cs b/LibGit2Sharp/UnmatchedPathException.cs
index 50d8cd70..19f061ef 100644
--- a/LibGit2Sharp/UnmatchedPathException.cs
+++ b/LibGit2Sharp/UnmatchedPathException.cs
@@ -45,10 +45,5 @@ namespace LibGit2Sharp
: base(info, context)
{
}
-
- internal UnmatchedPathException(string message, GitErrorCode code, GitErrorCategory category)
- : base(message, code, category)
- {
- }
}
}