diff --git a/CHANGES.md b/CHANGES.md index 4d880fdc5..01635ce59 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,7 +10,7 @@ - Windows (x86/amd64): - Linux/Mac OS X: -## v0.23 + 1 +## v0.23.1 + 1 ### Additions @@ -18,6 +18,13 @@ ### Fixes +## v0.23.1 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.23..v0.23.1)) + +### Fixes + + - Update to libgit2 0.25.1 which includes security fixes for smart + protocol parsing and TLS certificate validity check callbacks. + ## v0.23 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.22..v0.23)) ### Additions diff --git a/Install/WiX2/Source Files/Export/RedGate.ThirdParty.LibGit2Sharp.Fork.wxs b/Install/WiX2/Source Files/Export/RedGate.ThirdParty.LibGit2Sharp.Fork.wxs new file mode 100644 index 000000000..cfc840cf0 --- /dev/null +++ b/Install/WiX2/Source Files/Export/RedGate.ThirdParty.LibGit2Sharp.Fork.wxs @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LibGit2Sharp.Tests/MetaFixture.cs b/LibGit2Sharp.Tests/MetaFixture.cs index a3ff18f78..3e81b1e93 100644 --- a/LibGit2Sharp.Tests/MetaFixture.cs +++ b/LibGit2Sharp.Tests/MetaFixture.cs @@ -410,7 +410,7 @@ public void AllIDiffResultsAreInChangesBuilder() var nonBuilderTypes = diffResults.Where(diffResult => !changesBuilders.Contains(diffResult)); Assert.False(nonBuilderTypes.Any(), "Classes which implement IDiffResult but are not registered under ChangesBuilders in Diff:" + Environment.NewLine + - string.Join(Environment.NewLine, nonBuilderTypes.Select(type => type.FullName))); + string.Join(Environment.NewLine, nonBuilderTypes.Select(type => type.FullName).ToArray())); } } diff --git a/LibGit2Sharp.Tests/SetErrorFixture.cs b/LibGit2Sharp.Tests/SetErrorFixture.cs index b10a54108..fed74dae9 100644 --- a/LibGit2Sharp.Tests/SetErrorFixture.cs +++ b/LibGit2Sharp.Tests/SetErrorFixture.cs @@ -43,7 +43,7 @@ public void FormatExceptionWithInnerException() AssertExpectedExceptionMessage(expectedMessage, exceptionToThrow); } - [Fact] + [Fact(Skip = "Redgate: we're building for .NET 3.5 so not handling AggregateExceptions")] public void FormatAggregateException() { Exception exceptionToThrow = new AggregateException(aggregateExceptionMessage, new Exception(innerExceptionMessage), new Exception(innerExceptionMessage2)); diff --git a/LibGit2Sharp.Tests/app.config b/LibGit2Sharp.Tests/app.config index 5ab38dff7..2361e2088 100644 --- a/LibGit2Sharp.Tests/app.config +++ b/LibGit2Sharp.Tests/app.config @@ -8,4 +8,4 @@ - + diff --git a/LibGit2Sharp.sln b/LibGit2Sharp.sln index 765e8dd01..932ea2d9a 100644 --- a/LibGit2Sharp.sln +++ b/LibGit2Sharp.sln @@ -1,10 +1,21 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp", "LibGit2Sharp\LibGit2Sharp.csproj", "{EE6ED99F-CB12-4683-B055-D28FC7357A34}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp.Tests", "LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj", "{286E63EB-04DD-4ADE-88D6-041B57800761}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{004B66E5-1E40-4416-BA73-BBF84D36BDB2}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + LibGit2Sharp\CopyNativeDependencies.targets = LibGit2Sharp\CopyNativeDependencies.targets + nuget.package\LibGit2Sharp-RedGate.nuspec = nuget.package\LibGit2Sharp-RedGate.nuspec + LICENSE.md = LICENSE.md + README.md = README.md + EndProjectSection +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{19D079A4-A273-4630-B2D2-79EADE3E7CA1}" ProjectSection(SolutionItems) = preProject .nuget\packages.config = .nuget\packages.config diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs index 5a0aa03f3..bf5f7881e 100644 --- a/LibGit2Sharp/Configuration.cs +++ b/LibGit2Sharp/Configuration.cs @@ -109,7 +109,7 @@ private FilePath NormalizeConfigPath(FilePath path) return configPath; } - var gitConfigPath = Path.Combine(path.Native, ".git", "config"); + var gitConfigPath = Path.Combine(path.Native, Path.Combine(".git", "config")); if (File.Exists(gitConfigPath)) { diff --git a/LibGit2Sharp/CopyNativeDependencies.targets b/LibGit2Sharp/CopyNativeDependencies.targets new file mode 100644 index 000000000..20922be32 --- /dev/null +++ b/LibGit2Sharp/CopyNativeDependencies.targets @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/LibGit2Sharp/Core/Ensure.cs b/LibGit2Sharp/Core/Ensure.cs index d82fa3a4b..ff7b8acea 100644 --- a/LibGit2Sharp/Core/Ensure.cs +++ b/LibGit2Sharp/Core/Ensure.cs @@ -49,7 +49,7 @@ public static void ArgumentNotNullOrEmptyString(string argumentValue, string arg { ArgumentNotNull(argumentValue, argumentName); - if (String.IsNullOrWhiteSpace (argumentValue)) + if (argumentValue.IsNullOrWhiteSpace ()) { throw new ArgumentException("String cannot be empty", argumentName); } diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index e8ab4cc7a..f9f488d21 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; using System.IO; +using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; diff --git a/LibGit2Sharp/Core/Platform.cs b/LibGit2Sharp/Core/Platform.cs index 1f43b6a24..8e76d418b 100644 --- a/LibGit2Sharp/Core/Platform.cs +++ b/LibGit2Sharp/Core/Platform.cs @@ -9,11 +9,17 @@ internal enum OperatingSystemType MacOSX } + internal static class Platform { public static string ProcessorArchitecture { - get { return Environment.Is64BitProcess ? "x64" : "x86"; } + get { return Is64BitProcess ? "x64" : "x86"; } + } + + private static bool Is64BitProcess + { + get { return IntPtr.Size == 8; } } public static OperatingSystemType OperatingSystem diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index bf81a4a9d..9e42274eb 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -52,37 +52,7 @@ private static void BuildErrorMessageFromException(StringBuilder sb, int level, string indent = new string(' ', level * 4); sb.AppendFormat("{0}{1}", indent, ex.Message); - if (ex is AggregateException) - { - AggregateException aggregateException = ((AggregateException)ex).Flatten(); - - if (aggregateException.InnerExceptions.Count == 1) - { - sb.AppendLine(); - sb.AppendLine(); - - sb.AppendFormat("{0}Contained Exception:{1}", indent, Environment.NewLine); - BuildErrorMessageFromException(sb, level + 1, aggregateException.InnerException); - } - else - { - sb.AppendLine(); - sb.AppendLine(); - - sb.AppendFormat("{0}Contained Exceptions:{1}", indent, Environment.NewLine); - for (int i = 0; i < aggregateException.InnerExceptions.Count; i++) - { - if (i != 0) - { - sb.AppendLine(); - sb.AppendLine(); - } - - BuildErrorMessageFromException(sb, level + 1, aggregateException.InnerExceptions[i]); - } - } - } - else if (ex.InnerException != null) + if (ex.InnerException != null) { sb.AppendLine(); sb.AppendLine(); diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs index 9bf14660c..f19d0843a 100644 --- a/LibGit2Sharp/Diff.cs +++ b/LibGit2Sharp/Diff.cs @@ -114,7 +114,7 @@ private static T BuildDiffResult(DiffHandle diff) where T : class, IDiffResul if (!ChangesBuilders.TryGetValue(typeof(T), out builder)) { throw new LibGit2SharpException("User-defined types passed to Compare are not supported. Supported values are: {0}", - string.Join(", ", ChangesBuilders.Keys.Select(x => x.Name))); + string.Join(", ", ChangesBuilders.Keys.Select(x => x.Name).ToArray())); } return (T)builder(diff); diff --git a/LibGit2Sharp/Filter.cs b/LibGit2Sharp/Filter.cs index 050d4a83c..84261f9a1 100644 --- a/LibGit2Sharp/Filter.cs +++ b/LibGit2Sharp/Filter.cs @@ -35,7 +35,7 @@ protected Filter(string name, IEnumerable attributes) this.name = name; this.attributes = attributes; - var attributesAsString = string.Join(",", this.attributes.Select(attr => attr.FilterDefinition)); + var attributesAsString = string.Join(",", this.attributes.Select(attr => attr.FilterDefinition).ToArray()); gitFilter = new GitFilter { diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 6156af63b..9d3b75e50 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -1,6 +1,6 @@  - + Debug AnyCPU @@ -10,8 +10,8 @@ Library Properties LibGit2Sharp - LibGit2Sharp - v4.0 + LibGit2Sharp-RedGate + v3.5 512 @@ -43,11 +43,15 @@ true - libgit2sharp.snk + \\red-gate.com\files\RG_Build_Key\RedGate.snk + + ..\packages\TaskParallelLibrary.1.0.2856.0\lib\Net35\System.Threading.dll + True + @@ -120,6 +124,7 @@ + @@ -372,6 +377,9 @@ + + + @@ -392,6 +400,6 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/LibGit2Sharp/Net35.cs b/LibGit2Sharp/Net35.cs new file mode 100644 index 000000000..c9402600a --- /dev/null +++ b/LibGit2Sharp/Net35.cs @@ -0,0 +1,143 @@ +using System; +using System.IO; + +namespace LibGit2Sharp +{ + internal class Tuple + { + public T Item1 { get; private set; } + public TS Item2 { get; private set; } + + public Tuple(T item1, TS item2) + { + Item1 = item1; + Item2 = item2; + } + } + + internal static class EnumExt + { + /// + /// Check to see if a flags enumeration has a specific flag set. + /// + /// Flags enumeration to check + /// Flag to check for + /// + public static bool HasFlag(this Enum variable, Enum value) + { + if (variable == null) + return false; + + if (value == null) + throw new ArgumentNullException("value"); + + // Not as good as the .NET 4 version of this function, but should be good enough + if (!Enum.IsDefined(variable.GetType(), value)) + { + throw new ArgumentException(string.Format( + "Enumeration type mismatch. The flag is of type '{0}', was expecting '{1}'.", + value.GetType(), variable.GetType())); + } + + long num = Convert.ToInt64(value); + return (Convert.ToInt64(variable) & num) == num; + + } + + } + + /// + /// Provides support for lazy initialization. + /// + /// Specifies the type of object that is being lazily initialized. + internal class Lazy + { + private readonly object padlock = new object(); + private readonly Func createValue; + private bool isValueCreated; + private T value; + + /// + /// Gets the lazily initialized value of the current Lazy{T} instance. + /// + public T Value + { + get + { + if (!isValueCreated) + { + lock (padlock) + { + if (!isValueCreated) + { + value = createValue(); + isValueCreated = true; + } + } + } + return value; + } + } + + /// + /// Gets a value that indicates whether a value has been created for this Lazy{T} instance. + /// + public bool IsValueCreated + { + get + { + lock (padlock) + { + return isValueCreated; + } + } + } + + + /// + /// Initializes a new instance of the Lazy{T} class. + /// + /// The delegate that produces the value when it is needed. + public Lazy(Func createValue) + { + if (createValue == null) throw new ArgumentNullException("createValue"); + + this.createValue = createValue; + } + + + /// + /// Creates and returns a string representation of the Lazy{T}.Value. + /// + /// The string representation of the Lazy{T}.Value property. + public override string ToString() + { + return Value.ToString(); + } + } + + internal static class StreamExtensions + { + /// + /// For .NET 3.5. Copied from http://stackoverflow.com/a/5730893 + /// + public static void CopyTo(this Stream input, Stream output) + { + byte[] buffer = new byte[16 * 1024]; // Fairly arbitrary size + int bytesRead; + + while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0) + { + output.Write(buffer, 0, bytesRead); + } + } + } + + internal static class StringExtensions + { + public static bool IsNullOrWhiteSpace(this string s) + { + return string.IsNullOrEmpty(s) || s.Trim().Length == 0; + } + } +} diff --git a/LibGit2Sharp/Properties/AssemblyInfo.cs b/LibGit2Sharp/Properties/AssemblyInfo.cs index 34c8f06bd..0a86aca08 100644 --- a/LibGit2Sharp/Properties/AssemblyInfo.cs +++ b/LibGit2Sharp/Properties/AssemblyInfo.cs @@ -42,6 +42,6 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.23.0")] -[assembly: AssemblyFileVersion("0.23.0")] -[assembly: AssemblyInformationalVersion("0.23.0-dev00000000000000")] +[assembly: AssemblyVersion("0.23.1")] +[assembly: AssemblyFileVersion("0.23.1")] +[assembly: AssemblyInformationalVersion("0.23.1-dev00000000000000")] diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 7c4f2f1de..0e691913d 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -206,7 +206,7 @@ static public bool IsValid(string path) { Ensure.ArgumentNotNull(path, "path"); - if (string.IsNullOrWhiteSpace(path)) + if (path.IsNullOrWhiteSpace()) { return false; } diff --git a/LibGit2Sharp/Version.cs b/LibGit2Sharp/Version.cs index b4cbd88f0..48096c2a8 100644 --- a/LibGit2Sharp/Version.cs +++ b/LibGit2Sharp/Version.cs @@ -94,7 +94,7 @@ private string RetrieveVersion() InformationalVersion, LibGit2SharpCommitSha, LibGit2CommitSha, - Platform.ProcessorArchitecture, + Platform.ProcessorArchitecture.ToString(), features); } diff --git a/LibGit2Sharp/libgit2sharp.pfx b/LibGit2Sharp/libgit2sharp.pfx new file mode 100644 index 000000000..bfdb0dd1a Binary files /dev/null and b/LibGit2Sharp/libgit2sharp.pfx differ diff --git a/LibGit2Sharp/packages.config b/LibGit2Sharp/packages.config index db6ebf4c3..3dbdd9a27 100644 --- a/LibGit2Sharp/packages.config +++ b/LibGit2Sharp/packages.config @@ -1,4 +1,5 @@  - + + \ No newline at end of file diff --git a/nuget.package/LibGit2Sharp-RedGate.nuspec b/nuget.package/LibGit2Sharp-RedGate.nuspec new file mode 100644 index 000000000..0520cbfaa --- /dev/null +++ b/nuget.package/LibGit2Sharp-RedGate.nuspec @@ -0,0 +1,37 @@ + + + + RedGate.ThirdParty.LibGit2Sharp.Fork + 0.20.2.2 + Red Gate Software + nulltoken, Richard Mitchell + https://github.com/libgit2/libgit2sharp/raw/master/LICENSE.md + https://github.com/libgit2/libgit2sharp/ + false + LibGit2Sharp fork for Red Gate, .net3.5 and strongly named + https://github.com/libgit2/libgit2sharp/blob/master/CHANGES.md#libgit2sharp-changes + https://github.com/libgit2/libgit2sharp/raw/master/square-logo.png + libgit2 git wrapper bindings API dvcs vcs + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget.package/RedGate.ThirdParty.LibGit2Sharp.Fork.targets b/nuget.package/RedGate.ThirdParty.LibGit2Sharp.Fork.targets new file mode 100644 index 000000000..552dcf8f4 --- /dev/null +++ b/nuget.package/RedGate.ThirdParty.LibGit2Sharp.Fork.targets @@ -0,0 +1,24 @@ + + + + + lib\win32\x64\%(Filename)%(Extension) + PreserveNewest + + + lib\win32\x86\%(Filename)%(Extension) + PreserveNewest + + + + + %(Filename)%(Extension) + PreserveNewest + + +