Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix issues raised by Code Analysis

  • Loading branch information...
commit b62438b78d9676f6ca6d7c73440a80e3eb2bbc72 1 parent cda8d3f
@nulltoken nulltoken authored
Showing with 76 additions and 49 deletions.
  1. +2 −2 LibGit2Sharp.Tests/AttributesFixture.cs
  2. +1 −1  LibGit2Sharp.Tests/CommitFixture.cs
  3. +0 −1  LibGit2Sharp.Tests/LazyFixture.cs
  4. +1 −3 LibGit2Sharp.Tests/ObjectIdFixture.cs
  5. +1 −1  LibGit2Sharp.Tests/ResetIndexFixture.cs
  6. +1 −1  LibGit2Sharp.Tests/StatusFixture.cs
  7. +0 −1  LibGit2Sharp.Tests/TupleFixture.cs
  8. +0 −1  LibGit2Sharp/Blob.cs
  9. +5 −0 LibGit2Sharp/BlobExtensions.cs
  10. +0 −6 LibGit2Sharp/Changes.cs
  11. +1 −0  LibGit2Sharp/CommitLog.cs
  12. +2 −1  LibGit2Sharp/Core/Handles/SafeHandleBase.cs
  13. +1 −1  LibGit2Sharp/Core/NativeMethods.cs
  14. +1 −2  LibGit2Sharp/Core/UnSafeNativeMethods.cs
  15. +2 −2 LibGit2Sharp/Core/Utf8Marshaler.cs
  16. +2 −0  LibGit2Sharp/CustomDictionary.xml
  17. +5 −0 LibGit2Sharp/Diff.cs
  18. +5 −5 LibGit2Sharp/Index.cs
  19. +12 −0 LibGit2Sharp/LibGit2SharpException.cs
  20. +1 −1  LibGit2Sharp/Mode.cs
  21. +1 −1  LibGit2Sharp/Note.cs
  22. +3 −3 LibGit2Sharp/NoteCollection.cs
  23. +4 −0 LibGit2Sharp/ObjectDatabase.cs
  24. +0 −6 LibGit2Sharp/Reference.cs
  25. +7 −2 LibGit2Sharp/ReferenceWrapper.cs
  26. +7 −2 LibGit2Sharp/Repository.cs
  27. +8 −4 LibGit2Sharp/TreeDefinition.cs
  28. +2 −1  LibGit2Sharp/TreeEntry.cs
  29. +1 −1  LibGit2Sharp/TreeEntryDefinition.cs
View
4 LibGit2Sharp.Tests/AttributesFixture.cs
@@ -21,7 +21,7 @@ public void StagingHonorsTheAttributesFiles()
}
}
- private void AssertNormalization(Repository repo, string filename, bool shouldHaveBeenNormalized, string expectedSha)
+ private static void AssertNormalization(Repository repo, string filename, bool shouldHaveBeenNormalized, string expectedSha)
{
var sb = new StringBuilder();
sb.Append("I'm going to be dynamically processed\r\n");
@@ -44,7 +44,7 @@ private void AssertNormalization(Repository repo, string filename, bool shouldHa
Assert.Equal(!shouldHaveBeenNormalized, blob.ContentAsUtf8().Contains("\r"));
}
- private void CreateAttributesFile(Repository repo)
+ private static void CreateAttributesFile(Repository repo)
{
const string relativePath = ".gitattributes";
string fullFilePath = Path.Combine(repo.Info.WorkingDirectory, relativePath);
View
2  LibGit2Sharp.Tests/CommitFixture.cs
@@ -631,7 +631,7 @@ private static void CreateAndStageANewFile(Repository repo)
repo.Index.Stage(relativeFilepath);
}
- private void AssertCommitHasBeenAmended(Repository repo, Commit amendedCommit, Commit originalCommit)
+ private static void AssertCommitHasBeenAmended(Repository repo, Commit amendedCommit, Commit originalCommit)
{
Commit headCommit = repo.Head.Tip;
Assert.Equal(amendedCommit, headCommit);
View
1  LibGit2Sharp.Tests/LazyFixture.cs
@@ -1,6 +1,5 @@
using System;
using LibGit2Sharp.Core.Compat;
-using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
namespace LibGit2Sharp.Tests
View
4 LibGit2Sharp.Tests/ObjectIdFixture.cs
@@ -1,6 +1,4 @@
using System;
-using System.Linq;
-using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
@@ -11,7 +9,7 @@ public class ObjectIdFixture
private const string validSha1 = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09";
private const string validSha2 = "de08fe4884650f067bd5703b6a59a8b3b3c99a09";
- private static byte[] bytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9 };
+ private static readonly byte[] bytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9 };
[Theory]
[InlineData("Dummy", typeof(ArgumentException))]
View
2  LibGit2Sharp.Tests/ResetIndexFixture.cs
@@ -30,7 +30,7 @@ public void ResettingInABareRepositoryThrows()
}
}
- private bool IsStaged(StatusEntry entry)
+ private static bool IsStaged(StatusEntry entry)
{
if ((entry.State & FileStatus.Added) == FileStatus.Added)
{
View
2  LibGit2Sharp.Tests/StatusFixture.cs
@@ -133,7 +133,7 @@ public void RetrievingTheStatusOfAnEmptyRepositoryHonorsTheGitIgnoreDirectives()
using (Repository repo = Repository.Init(scd.DirectoryPath))
{
- string relativePath = "look-ma.txt";
+ const string relativePath = "look-ma.txt";
string fullFilePath = Path.Combine(repo.Info.WorkingDirectory, relativePath);
File.WriteAllText(fullFilePath, "I'm going to be ignored!");
View
1  LibGit2Sharp.Tests/TupleFixture.cs
@@ -1,5 +1,4 @@
using LibGit2Sharp.Core.Compat;
-using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
namespace LibGit2Sharp.Tests
View
1  LibGit2Sharp/Blob.cs
@@ -1,7 +1,6 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
-using System.Text;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Handles;
View
5 LibGit2Sharp/BlobExtensions.cs
@@ -1,4 +1,5 @@
using System.Text;
+using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
@@ -14,6 +15,8 @@ public static class BlobExtensions
/// <returns>Blob content as UTF-8</returns>
public static string ContentAsUtf8(this Blob blob)
{
+ Ensure.ArgumentNotNull(blob, "blob");
+
return Encoding.UTF8.GetString(blob.Content);
@Aimeast
Aimeast added a note

Bug when a blob has BOM.
Should use new StreamReader(stream, utf8, true) to identify the encoding.

@nulltoken Owner

@Aimeast rather than an online comment, could you please open an issue? Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
@@ -24,6 +27,8 @@ public static string ContentAsUtf8(this Blob blob)
/// <returns>Blob content as unicode.</returns>
public static string ContentAsUnicode(this Blob blob)
{
+ Ensure.ArgumentNotNull(blob, "blob");
+
return Encoding.Unicode.GetString(blob.Content);
}
}
View
6 LibGit2Sharp/Changes.cs
@@ -9,12 +9,6 @@ public abstract class Changes
{
private readonly StringBuilder patchBuilder = new StringBuilder();
- /// <summary>
- /// Needed for mocking purposes.
- /// </summary>
- protected Changes()
- { }
-
internal void AppendToPatch(string patch)
{
patchBuilder.Append(patch);
View
1  LibGit2Sharp/CommitLog.cs
@@ -166,6 +166,7 @@ public virtual Commit FindCommonAncestor(Commit first, Commit second)
public virtual Commit FindCommonAncestor(IEnumerable<Commit> commits)
{
Ensure.ArgumentNotNull(commits, "commits");
+
Commit ret = null;
int count = 0;
View
3  LibGit2Sharp/Core/Handles/SafeHandleBase.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Globalization;
using System.Runtime.InteropServices;
namespace LibGit2Sharp.Core.Handles
@@ -23,7 +24,7 @@ protected override void Dispose(bool disposing)
#if DEBUG
if (!disposing && !IsInvalid)
{
- Trace.WriteLine(string.Format("A {0} handle wrapper has not been properly disposed.", GetType().Name));
+ Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "A {0} handle wrapper has not been properly disposed.", GetType().Name));
#if LEAKS
Trace.WriteLine(trace);
#endif
View
2  LibGit2Sharp/Core/NativeMethods.cs
@@ -718,6 +718,6 @@ public static bool RepositoryStateChecker(RepositorySafeHandle repositoryPtr, Fu
public static extern int git_treebuilder_write(out GitOid oid, RepositorySafeHandle repo, TreeBuilderSafeHandle bld);
[DllImport(libgit2)]
- public static extern int git_treebuilder_free(IntPtr bld);
+ public static extern void git_treebuilder_free(IntPtr bld);

The old line is the actual contract of this function, don't change this

@nulltoken Owner

Hmmm. Sure? This is very old commit. Like dinosaur-old... :wink:

Yeah, I realized it once I made the comment, I don't know why I got a notification for it. GitHub, who writes this crap??

@nulltoken Owner

:sparkles: :heart:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
}
View
3  LibGit2Sharp/Core/UnSafeNativeMethods.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
using LibGit2Sharp.Core.Handles;
namespace LibGit2Sharp.Core
View
4 LibGit2Sharp/Core/Utf8Marshaler.cs
@@ -31,7 +31,7 @@ public virtual IntPtr MarshalManagedToNative(object managedObj)
return StringToNative((string)managedObj);
}
- protected unsafe IntPtr StringToNative(string value)
+ protected static unsafe IntPtr StringToNative(string value)
{
// not null terminated
byte[] strbuf = Encoding.UTF8.GetBytes(value);
@@ -50,7 +50,7 @@ public virtual object MarshalNativeToManaged(IntPtr pNativeData)
return NativeToString(pNativeData);
}
- protected unsafe string NativeToString(IntPtr pNativeData)
+ protected static unsafe string NativeToString(IntPtr pNativeData)
{
var walk = (byte*)pNativeData;
View
2  LibGit2Sharp/CustomDictionary.xml
@@ -8,6 +8,8 @@
<Word>sha</Word>
<Word>unstage</Word>
<Word>unstaged</Word>
+ <Word>compat</Word>
+ <Word>oid</Word>
</Recognized>
<Deprecated>
<Term PreferredAlternate=""></Term>
View
5 LibGit2Sharp/Diff.cs
@@ -70,6 +70,9 @@ internal Diff(Repository repo)
/// <returns>A <see cref = "TreeChanges"/> containing the changes between the <paramref name = "oldTree"/> and the <paramref name = "newTree"/>.</returns>
public virtual TreeChanges Compare(Tree oldTree, Tree newTree, IEnumerable<string> paths = null)
{
+ Ensure.ArgumentNotNull(oldTree, "oldTree");
+ Ensure.ArgumentNotNull(oldTree, "newTree");
+
using(GitDiffOptions options = BuildOptions(paths))
using (DiffListSafeHandle diff = BuildDiffListFromTrees(oldTree.Id, newTree.Id, options))
{
@@ -122,6 +125,8 @@ public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob)
/// <returns>A <see cref = "TreeChanges"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns>
public virtual TreeChanges Compare(Tree oldTree, DiffTarget diffTarget, IEnumerable<string> paths = null)
{
+ Ensure.ArgumentNotNull(oldTree, "oldTree");
+
var comparer = handleRetrieverDispatcher[diffTarget](repo);
using (GitDiffOptions options = BuildOptions(paths))
View
10 LibGit2Sharp/Index.cs
@@ -133,7 +133,7 @@ public virtual void Stage(IEnumerable<string> paths)
//TODO: Stage() should support following use cases:
// - Recursively staging the content of a directory
- IDictionary<string, FileStatus> batch = PrepareBatch(paths);
+ IEnumerable<KeyValuePair<string, FileStatus>> batch = PrepareBatch(paths);
foreach (KeyValuePair<string, FileStatus> kvp in batch)
{
@@ -289,7 +289,7 @@ public virtual void Remove(IEnumerable<string> paths)
//TODO: Remove() should support following use cases:
// - Removing a directory and its content
- IDictionary<string, FileStatus> batch = PrepareBatch(paths);
+ IEnumerable<KeyValuePair<string, FileStatus>> batch = PrepareBatch(paths);
foreach (KeyValuePair<string, FileStatus> keyValuePair in batch)
{
@@ -320,7 +320,7 @@ public virtual void Remove(IEnumerable<string> paths)
UpdatePhysicalIndex();
}
- private IDictionary<string, FileStatus> PrepareBatch(IEnumerable<string> paths)
+ private IEnumerable<KeyValuePair<string, FileStatus>> PrepareBatch(IEnumerable<string> paths)
{
Ensure.ArgumentNotNull(paths, "paths");
@@ -370,7 +370,7 @@ public virtual void Remove(IEnumerable<string> paths)
return new Tuple<string, FileStatus>(relativePath, RetrieveStatus(relativePath));
}
- private bool Enumerate(IEnumerator<string> leftEnum, IEnumerator<string> rightEnum)
+ private static bool Enumerate(IEnumerator<string> leftEnum, IEnumerator<string> rightEnum)
{
bool isLeftEoF = leftEnum.MoveNext();
bool isRightEoF = rightEnum.MoveNext();
@@ -484,7 +484,7 @@ internal void Reset(TreeChanges changes)
continue;
default:
- throw new InvalidOperationException(string.Format("Entry '{0}' bears an unexpected ChangeKind '{1}'", treeEntryChanges.Path, treeEntryChanges.Status));
+ throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Entry '{0}' bears an unexpected ChangeKind '{1}'", treeEntryChanges.Path, treeEntryChanges.Status));
}
}
View
12 LibGit2Sharp/LibGit2SharpException.cs
@@ -1,4 +1,5 @@
using System;
+using System.Runtime.Serialization;
namespace LibGit2Sharp
{
@@ -38,6 +39,7 @@ public LibGit2Exception(string message, Exception innerException)
/// <summary>
/// The exception that is thrown when an error occurs during application execution.
/// </summary>
+ [Serializable]
public class LibGit2SharpException : Exception
{
/// <summary>
@@ -65,5 +67,15 @@ public LibGit2SharpException(string message, Exception innerException)
: base(message, innerException)
{
}
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref = "LibGit2SharpException" /> class with a serialized data.
+ /// </summary>
+ /// <param name = "info">The <see cref="SerializationInfo "/> that holds the serialized object data about the exception being thrown.</param>
+ /// <param name = "context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
+ protected LibGit2SharpException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ }
}
}
View
2  LibGit2Sharp/Mode.cs
@@ -25,7 +25,7 @@ public enum Mode
/// <summary>
/// 100664 file mode
/// </summary>
- NonExecutableGroupWriteableFile = 0x81B4,
+ NonExecutableGroupWritableFile = 0x81B4,
/// <summary>
/// 100755 file mode
View
2  LibGit2Sharp/Note.cs
@@ -44,7 +44,7 @@ private Note(ObjectId blobId, string message, ObjectId targetObjectId, string @n
/// </summary>
public virtual ObjectId TargetObjectId { get; private set; }
- internal static Note BuildFromPtr(Repository repo, string @namespace, ObjectId targetObjectId, NoteSafeHandle note)
+ internal static Note BuildFromPtr(string @namespace, ObjectId targetObjectId, NoteSafeHandle note)
{
ObjectId oid = NativeMethods.git_note_oid(note).MarshalAsObjectId();
string message = NativeMethods.git_note_message(note);
View
6 LibGit2Sharp/NoteCollection.cs
@@ -78,7 +78,7 @@ internal IEnumerable<string> NamespaceRefs
return new[] { NormalizeToCanonicalName(DefaultNamespace) }.Concat(
from reference in repo.Refs
select reference.CanonicalName into refCanonical
- where refCanonical.StartsWith(refsNotesPrefix) && refCanonical != NormalizeToCanonicalName(DefaultNamespace)
+ where refCanonical.StartsWith(refsNotesPrefix, StringComparison.Ordinal) && refCanonical != NormalizeToCanonicalName(DefaultNamespace)
select refCanonical);
}
}
@@ -124,7 +124,7 @@ internal Note RetrieveNote(ObjectId targetObjectId, string canonicalNamespace)
return null;
}
- return Note.BuildFromPtr(repo, UnCanonicalizeName(canonicalNamespace), targetObjectId, noteHandle);
+ return Note.BuildFromPtr(UnCanonicalizeName(canonicalNamespace), targetObjectId, noteHandle);
}
}
@@ -153,7 +153,7 @@ private NoteSafeHandle BuildNoteSafeHandle(ObjectId id, string canonicalNamespac
return noteHandle;
}
- internal string NormalizeToCanonicalName(string name)
+ internal static string NormalizeToCanonicalName(string name)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
View
4 LibGit2Sharp/ObjectDatabase.cs
@@ -37,6 +37,8 @@ internal ObjectDatabase(Repository repo)
/// <returns>True if the object has been found; false otherwise.</returns>
public virtual bool Contains(ObjectId objectId)
{
+ Ensure.ArgumentNotNull(objectId, "objectId");
+
var oid = objectId.Oid;
return NativeMethods.git_odb_exists(handle, ref oid) != (int)GitErrorCode.Ok;
@@ -72,6 +74,8 @@ public virtual Blob CreateBlob(string path)
/// <returns>The created <see cref = "Tree"/>.</returns>
public virtual Tree CreateTree(TreeDefinition treeDefinition)
{
+ Ensure.ArgumentNotNull(treeDefinition, "treeDefinition");
+
return treeDefinition.Build(repo);
}
View
6 LibGit2Sharp/Reference.cs
@@ -15,12 +15,6 @@ public abstract class Reference : IEquatable<Reference>
new LambdaEqualityHelper<Reference>(new Func<Reference, object>[] { x => x.CanonicalName, x => x.TargetIdentifier });
/// <summary>
- /// Needed for mocking purposes.
- /// </summary>
- protected Reference()
- { }
-
- /// <summary>
/// Gets the full name of this reference.
/// </summary>
public virtual string CanonicalName { get; protected set; }
View
9 LibGit2Sharp/ReferenceWrapper.cs
@@ -19,6 +19,8 @@ public abstract class ReferenceWrapper<TObject> : IEquatable<ReferenceWrapper<TO
private static readonly LambdaEqualityHelper<ReferenceWrapper<TObject>> equalityHelper =
new LambdaEqualityHelper<ReferenceWrapper<TObject>>(new Func<ReferenceWrapper<TObject>, object>[] { x => x.CanonicalName, x => x.TargetObject });
+ private readonly string canonicalName;
+
/// <summary>
/// Needed for mocking purposes.
/// </summary>
@@ -35,14 +37,17 @@ protected internal ReferenceWrapper(Repository repo, Reference reference, Func<R
Ensure.ArgumentNotNull(canonicalNameSelector, "canonicalNameSelector");
this.repo = repo;
- CanonicalName = canonicalNameSelector(reference);
+ canonicalName = canonicalNameSelector(reference);
objectBuilder = new Lazy<TObject>(() => RetrieveTargetObject(reference));
}
/// <summary>
/// Gets the full name of this reference.
/// </summary>
- public virtual string CanonicalName { get; protected set; }
+ public virtual string CanonicalName
+ {
+ get { return canonicalName; }
+ }
/// <summary>
/// Gets the name of this reference.
View
9 LibGit2Sharp/Repository.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -441,6 +442,7 @@ public Branch Checkout(string shaOrReferenceName)
public Branch Checkout(Branch branch)
{
Ensure.ArgumentNotNull(branch, "branch");
+
Refs.UpdateTarget("HEAD", branch.CanonicalName);
return branch;
}
@@ -569,7 +571,9 @@ private static string RetrieveVersion()
string libgit2Hash = ReadContentFromResource(assembly, "libgit2_hash.txt");
string libgit2sharpHash = ReadContentFromResource(assembly, "libgit2sharp_hash.txt");
- return string.Format("{0}-{1}-{2} ({3})",
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0}-{1}-{2} ({3})",
version.ToString(3),
libgit2sharpHash.Substring(0, 7),
libgit2Hash.Substring(0, 7),
@@ -579,7 +583,8 @@ private static string RetrieveVersion()
private static string ReadContentFromResource(Assembly assembly, string partialResourceName)
{
- using (var sr = new StreamReader(assembly.GetManifestResourceStream(string.Format("LibGit2Sharp.{0}", partialResourceName))))
+ string name = string.Format(CultureInfo.InvariantCulture, "LibGit2Sharp.{0}", partialResourceName);
+ using (var sr = new StreamReader(assembly.GetManifestResourceStream(name)))
{
return sr.ReadLine();
}
View
12 LibGit2Sharp/TreeDefinition.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Compat;
@@ -103,7 +104,10 @@ public TreeDefinition Add(string targetTreeEntryPath, TreeEntryDefinition treeEn
if (treeEntryDefinition is TransientTreeTreeEntryDefinition)
{
- throw new InvalidOperationException(string.Format("The {0} references a target which hasn't been created in the {1} yet. This situation can occur when the target is a whole new {2} being created, or when an existing {2} is being updated because some of its children were added/removed.", typeof(TreeEntryDefinition).Name, typeof(ObjectDatabase).Name, typeof(Tree).Name));
+ throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
+ "The {0} references a target which hasn't been created in the {1} yet. " +
+ "This situation can occur when the target is a whole new {2} being created, or when an existing {2} is being updated because some of its children were added/removed.",
+ typeof(TreeEntryDefinition).Name, typeof(ObjectDatabase).Name, typeof(Tree).Name));
}
Tuple<string, string> segments = ExtractPosixLeadingSegment(targetTreeEntryPath);
@@ -132,7 +136,7 @@ public TreeDefinition Add(string targetTreeEntryPath, Blob blob, Mode mode)
{
Ensure.ArgumentNotNull(blob, "blob");
Ensure.ArgumentConformsTo(mode,
- m => m.HasAny(new[] { Mode.ExecutableFile, Mode.NonExecutableFile, Mode.NonExecutableGroupWriteableFile }), "mode");
+ m => m.HasAny(new[] { Mode.ExecutableFile, Mode.NonExecutableFile, Mode.NonExecutableGroupWritableFile }), "mode");
TreeEntryDefinition ted = TreeEntryDefinition.From(blob, mode);
@@ -299,9 +303,9 @@ private void WrapTree(string entryName, TreeEntryDefinition treeEntryDefinition)
{
string[] segments = targetPath.Posix.Split(new[] { '/' }, 2);
- if (segments[0] == string.Empty || (segments.Length == 2 && (segments[1] == string.Empty || segments[1].StartsWith("/"))))
+ if (segments[0] == string.Empty || (segments.Length == 2 && (segments[1] == string.Empty || segments[1].StartsWith("/", StringComparison.Ordinal))))
{
- throw new ArgumentException(string.Format("'{0}' is not a valid path.", targetPath));
+ throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "'{0}' is not a valid path.", targetPath));
}
return new Tuple<string, string>(segments[0], segments.Length == 2 ? segments[1] : null);
View
3  LibGit2Sharp/TreeEntry.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Compat;
using LibGit2Sharp.Core.Handles;
@@ -76,7 +77,7 @@ private GitObject RetrieveTreeEntryTarget()
{
if (!Type.HasAny(new[]{GitObjectType.Tree, GitObjectType.Blob}))
{
- throw new InvalidOperationException(string.Format("TreeEntry target of type '{0}' are not supported.", Type));
+ throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "TreeEntry target of type '{0}' are not supported.", Type));
}
GitObject treeEntryTarget = repo.LookupTreeEntryTarget(targetOid, Path);
View
2  LibGit2Sharp/TreeEntryDefinition.cs
@@ -65,7 +65,7 @@ internal static TreeEntryDefinition From(Blob blob, Mode mode)
internal static TreeEntryDefinition TransientBlobFrom(string filePath, Mode mode)
{
- Ensure.ArgumentConformsTo(mode, m => m.HasAny(new[] { Mode.NonExecutableFile, Mode.ExecutableFile, Mode.NonExecutableGroupWriteableFile }), "mode");
+ Ensure.ArgumentConformsTo(mode, m => m.HasAny(new[] { Mode.NonExecutableFile, Mode.ExecutableFile, Mode.NonExecutableGroupWritableFile }), "mode");
return new TransientBlobTreeEntryDefinition
{
@Aimeast

Bug when a blob has BOM.
Should use new StreamReader(stream, utf8, true) to identify the encoding.

@paulcbetts

The old line is the actual contract of this function, don't change this

@nulltoken

@Aimeast rather than an online comment, could you please open an issue? Thanks in advance!

@nulltoken

Hmmm. Sure? This is very old commit. Like dinosaur-old... :wink:

@paulcbetts

Yeah, I realized it once I made the comment, I don't know why I got a notification for it. GitHub, who writes this crap??

Please sign in to comment.
Something went wrong with that request. Please try again.