diff options
Diffstat (limited to 'LibGit2Sharp/Core')
27 files changed, 291 insertions, 187 deletions
diff --git a/LibGit2Sharp/Core/EncodingMarshaler.cs b/LibGit2Sharp/Core/EncodingMarshaler.cs index ad85c5ec..f76b9e46 100644 --- a/LibGit2Sharp/Core/EncodingMarshaler.cs +++ b/LibGit2Sharp/Core/EncodingMarshaler.cs @@ -43,8 +43,9 @@ namespace LibGit2Sharp.Core if (str == null) { - throw new MarshalDirectiveException( - string.Format(CultureInfo.InvariantCulture, "{0} must be used on a string.", GetType().Name)); + throw new MarshalDirectiveException(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 04303ca3..c0016e80 100644 --- a/LibGit2Sharp/Core/Ensure.cs +++ b/LibGit2Sharp/Core/Ensure.cs @@ -256,8 +256,8 @@ namespace LibGit2Sharp.Core } var message = string.Format(CultureInfo.InvariantCulture, - "No valid git object identified by '{0}' exists in the repository.", - identifier); + "No valid git object identified by '{0}' exists in the repository.", + identifier); if (string.Equals("HEAD", identifier, StringComparison.Ordinal)) { diff --git a/LibGit2Sharp/Core/FileHistory.cs b/LibGit2Sharp/Core/FileHistory.cs index 42a1aa2f..477717c7 100644 --- a/LibGit2Sharp/Core/FileHistory.cs +++ b/LibGit2Sharp/Core/FileHistory.cs @@ -72,9 +72,10 @@ namespace LibGit2Sharp.Core // Ensure the commit sort strategy makes sense. if (!AllowedSortStrategies.Contains(queryFilter.SortBy)) - throw new ArgumentException( - "Unsupported sort strategy. Only 'Topological', 'Time', or 'Topological | Time' are allowed.", - "queryFilter"); + { + throw new ArgumentException("Unsupported sort strategy. Only 'Topological', 'Time', or 'Topological | Time' are allowed.", + "queryFilter"); + } _repo = repo; _path = path; diff --git a/LibGit2Sharp/Core/FilePath.cs b/LibGit2Sharp/Core/FilePath.cs index 3d547aab..097d3228 100644 --- a/LibGit2Sharp/Core/FilePath.cs +++ b/LibGit2Sharp/Core/FilePath.cs @@ -60,7 +60,9 @@ namespace LibGit2Sharp.Core public bool Equals(FilePath other) { - return other == null ? posix == null : string.Equals(posix, other.posix, StringComparison.Ordinal); + return other == null + ? posix == null + : string.Equals(posix, other.posix, StringComparison.Ordinal); } public override bool Equals(object obj) diff --git a/LibGit2Sharp/Core/FilePathMarshaler.cs b/LibGit2Sharp/Core/FilePathMarshaler.cs index 2732b77d..56d42444 100644 --- a/LibGit2Sharp/Core/FilePathMarshaler.cs +++ b/LibGit2Sharp/Core/FilePathMarshaler.cs @@ -68,8 +68,9 @@ namespace LibGit2Sharp.Core if (null == filePath) { - throw new MarshalDirectiveException( - string.Format(CultureInfo.InvariantCulture, "{0} must be used on a FilePath.", GetType().Name)); + throw new MarshalDirectiveException(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 fd08b991..9db09390 100644 --- a/LibGit2Sharp/Core/GitBlame.cs +++ b/LibGit2Sharp/Core/GitBlame.cs @@ -37,7 +37,7 @@ namespace LibGit2Sharp.Core /// Restrict the search of commits to those reachable /// following only the first parents. /// </summary> - GIT_BLAME_FIRST_PARENT = (1<<4), + GIT_BLAME_FIRST_PARENT = (1 << 4), } [StructLayout(LayoutKind.Sequential)] @@ -79,8 +79,9 @@ namespace LibGit2Sharp.Core return GitBlameOptionFlags.GIT_BLAME_NORMAL; default: - throw new NotSupportedException( - string.Format(CultureInfo.InvariantCulture, "{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/GitCheckoutOptsWrapper.cs b/LibGit2Sharp/Core/GitCheckoutOptsWrapper.cs index 26614fa9..0fba8275 100644 --- a/LibGit2Sharp/Core/GitCheckoutOptsWrapper.cs +++ b/LibGit2Sharp/Core/GitCheckoutOptsWrapper.cs @@ -66,12 +66,15 @@ namespace LibGit2Sharp.Core case CheckoutFileConflictStrategy.Ours: flags = CheckoutStrategy.GIT_CHECKOUT_USE_OURS; break; + case CheckoutFileConflictStrategy.Theirs: flags = CheckoutStrategy.GIT_CHECKOUT_USE_THEIRS; break; + case CheckoutFileConflictStrategy.Merge: flags = CheckoutStrategy.GIT_CHECKOUT_CONFLICT_STYLE_MERGE; break; + case CheckoutFileConflictStrategy.Diff3: flags = CheckoutStrategy.GIT_CHECKOUT_CONFLICT_STYLE_DIFF3; break; diff --git a/LibGit2Sharp/Core/GitFilter.cs b/LibGit2Sharp/Core/GitFilter.cs index 1b177a8e..9074c771 100644 --- a/LibGit2Sharp/Core/GitFilter.cs +++ b/LibGit2Sharp/Core/GitFilter.cs @@ -70,7 +70,10 @@ namespace LibGit2Sharp.Core /// callback to free the payload. /// </summary> public delegate int git_filter_check_fn( - GitFilter gitFilter, IntPtr payload, IntPtr filterSource, IntPtr attributeValues); + GitFilter gitFilter, + IntPtr payload, + IntPtr filterSource, + IntPtr attributeValues); /// <summary> /// Callback to actually perform the data filtering @@ -83,10 +86,18 @@ namespace LibGit2Sharp.Core /// The `payload` value will refer to any payload that was set by the `check` callback. It may be read from or written to as needed. /// </summary> public delegate int git_filter_apply_fn( - GitFilter gitFilter, IntPtr payload, IntPtr gitBufTo, IntPtr gitBufFrom, IntPtr filterSource); + GitFilter gitFilter, + IntPtr payload, + IntPtr gitBufTo, + IntPtr gitBufFrom, + IntPtr filterSource); public delegate int git_filter_stream_fn( - out IntPtr git_writestream_out, GitFilter self, IntPtr payload, IntPtr filterSource, IntPtr git_writestream_next); + out IntPtr git_writestream_out, + GitFilter self, + IntPtr payload, + IntPtr filterSource, + IntPtr git_writestream_next); /// <summary> /// Callback to clean up after filtering has been applied. Specified as `filter.cleanup`, this is an optional callback invoked diff --git a/LibGit2Sharp/Core/GitObjectLazyGroup.cs b/LibGit2Sharp/Core/GitObjectLazyGroup.cs index 7d442916..824cc92c 100644 --- a/LibGit2Sharp/Core/GitObjectLazyGroup.cs +++ b/LibGit2Sharp/Core/GitObjectLazyGroup.cs @@ -26,7 +26,9 @@ namespace LibGit2Sharp.Core return Singleton(() => { using (var osw = new ObjectSafeWrapper(id, repo.Handle)) + { return resultSelector(osw.ObjectPtr); + } }); } } diff --git a/LibGit2Sharp/Core/GitObjectType.cs b/LibGit2Sharp/Core/GitObjectType.cs index a38523f2..50d8412c 100644 --- a/LibGit2Sharp/Core/GitObjectType.cs +++ b/LibGit2Sharp/Core/GitObjectType.cs @@ -75,8 +75,9 @@ namespace LibGit2Sharp.Core return TreeEntryTargetType.Blob; default: - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, "Cannot map {0} to a TreeEntryTargetType.", type)); + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, + "Cannot map {0} to a TreeEntryTargetType.", + type)); } } @@ -97,8 +98,9 @@ namespace LibGit2Sharp.Core return ObjectType.Tag; default: - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, "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/GitOdbBackendStream.cs b/LibGit2Sharp/Core/GitOdbBackendStream.cs index f7eec27d..30477ecb 100644 --- a/LibGit2Sharp/Core/GitOdbBackendStream.cs +++ b/LibGit2Sharp/Core/GitOdbBackendStream.cs @@ -48,11 +48,8 @@ namespace LibGit2Sharp.Core IntPtr buffer, UIntPtr len); - public delegate int finalize_write_callback( - IntPtr stream, - ref GitOid oid); + public delegate int finalize_write_callback(IntPtr stream, ref GitOid oid); - public delegate void free_callback( - IntPtr stream); + public delegate void free_callback(IntPtr stream); } } diff --git a/LibGit2Sharp/Core/GitRepositoryInitOptions.cs b/LibGit2Sharp/Core/GitRepositoryInitOptions.cs index c42bc83f..f639a0d8 100644 --- a/LibGit2Sharp/Core/GitRepositoryInitOptions.cs +++ b/LibGit2Sharp/Core/GitRepositoryInitOptions.cs @@ -19,10 +19,10 @@ namespace LibGit2Sharp.Core public static GitRepositoryInitOptions BuildFrom(FilePath workdirPath, bool isBare) { var opts = new GitRepositoryInitOptions - { - Flags = GitRepositoryInitFlags.GIT_REPOSITORY_INIT_MKPATH, - Mode = 0 /* GIT_REPOSITORY_INIT_SHARED_UMASK */ - }; + { + Flags = GitRepositoryInitFlags.GIT_REPOSITORY_INIT_MKPATH, + Mode = 0 /* GIT_REPOSITORY_INIT_SHARED_UMASK */ + }; if (workdirPath != null) { diff --git a/LibGit2Sharp/Core/GitRevertOpts.cs b/LibGit2Sharp/Core/GitRevertOpts.cs index 7976243c..3d6583a8 100644 --- a/LibGit2Sharp/Core/GitRevertOpts.cs +++ b/LibGit2Sharp/Core/GitRevertOpts.cs @@ -12,6 +12,6 @@ namespace LibGit2Sharp.Core public GitMergeOpts MergeOpts = new GitMergeOpts { Version = 1 }; - public GitCheckoutOpts CheckoutOpts = new GitCheckoutOpts {version = 1}; + public GitCheckoutOpts CheckoutOpts = new GitCheckoutOpts { version = 1 }; } } diff --git a/LibGit2Sharp/Core/GitSmartSubtransportStream.cs b/LibGit2Sharp/Core/GitSmartSubtransportStream.cs index f73218c0..16155aeb 100644 --- a/LibGit2Sharp/Core/GitSmartSubtransportStream.cs +++ b/LibGit2Sharp/Core/GitSmartSubtransportStream.cs @@ -36,7 +36,6 @@ namespace LibGit2Sharp.Core IntPtr buffer, UIntPtr len); - public delegate void free_callback( - IntPtr stream); + public delegate void free_callback(IntPtr stream); } } diff --git a/LibGit2Sharp/Core/GitWriteStream.cs b/LibGit2Sharp/Core/GitWriteStream.cs index dc1fd622..6739fd32 100644 --- a/LibGit2Sharp/Core/GitWriteStream.cs +++ b/LibGit2Sharp/Core/GitWriteStream.cs @@ -13,7 +13,7 @@ namespace LibGit2Sharp.Core public close_fn close; [MarshalAs(UnmanagedType.FunctionPtr)] - public free_fn free; + public free_fn free; public delegate int write_fn(IntPtr stream, IntPtr buffer, UIntPtr len); public delegate int close_fn(IntPtr stream); diff --git a/LibGit2Sharp/Core/HistoryRewriter.cs b/LibGit2Sharp/Core/HistoryRewriter.cs index d313bedb..de1b24ff 100644 --- a/LibGit2Sharp/Core/HistoryRewriter.cs +++ b/LibGit2Sharp/Core/HistoryRewriter.cs @@ -110,24 +110,33 @@ namespace LibGit2Sharp.Core var sref = reference as SymbolicReference; if (sref != null) { - return RewriteReference( - sref, old => old.Target, RewriteReference, - (refs, old, target, logMessage) => refs.UpdateTarget(old, target, logMessage)); + return RewriteReference(sref, + old => old.Target, + RewriteReference, + (refs, old, target, logMessage) => refs.UpdateTarget(old, + target, + logMessage)); } var dref = reference as DirectReference; if (dref != null) { - return RewriteReference( - dref, old => old.Target, RewriteTarget, - (refs, old, target, logMessage) => refs.UpdateTarget(old, target.Id, logMessage)); + return RewriteReference(dref, + old => old.Target, + RewriteTarget, + (refs, old, target, logMessage) => refs.UpdateTarget(old, + target.Id, + logMessage)); } return reference; } private delegate Reference ReferenceUpdater<in TRef, in TTarget>( - ReferenceCollection refs, TRef origRef, TTarget origTarget, string logMessage) + ReferenceCollection refs, + TRef origRef, + TTarget origTarget, + string logMessage) where TRef : Reference where TTarget : class; @@ -145,7 +154,8 @@ namespace LibGit2Sharp.Core { newRefName = Reference.TagPrefix + options.TagNameRewriter(oldRef.CanonicalName.Substring(Reference.TagPrefix.Length), - false, oldRef.TargetIdentifier); + false, + oldRef.TargetIdentifier); } var newTarget = rewriteTarget(oldRefTarget); @@ -160,10 +170,10 @@ namespace LibGit2Sharp.Core if (repo.Refs.Resolve<Reference>(backupName) != null) { - throw new InvalidOperationException( - String.Format( - CultureInfo.InvariantCulture, "Can't back up reference '{0}' - '{1}' already exists", - oldRef.CanonicalName, backupName)); + throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, + "Can't back up reference '{0}' - '{1}' already exists", + oldRef.CanonicalName, + backupName)); } repo.Refs.Add(backupName, oldRef.TargetIdentifier, "filter-branch: backup"); @@ -221,8 +231,7 @@ namespace LibGit2Sharp.Core // Create the new commit var mappedNewParents = newParents - .Select(oldParent => - objectMap.ContainsKey(oldParent) + .Select(oldParent => objectMap.ContainsKey(oldParent) ? objectMap[oldParent] as Commit : oldParent) .Where(newParent => newParent != null) @@ -293,8 +302,10 @@ namespace LibGit2Sharp.Core newName = options.TagNameRewriter(annotation.Name, true, annotation.Target.Sha); } - var newAnnotation = repo.ObjectDatabase.CreateTagAnnotation(newName, newTarget, annotation.Tagger, - annotation.Message); + var newAnnotation = repo.ObjectDatabase.CreateTagAnnotation(newName, + newTarget, + annotation.Tagger, + annotation.Message); objectMap[annotation] = newAnnotation; return newAnnotation; } @@ -303,8 +314,8 @@ namespace LibGit2Sharp.Core { var dref = reference as DirectReference; return dref == null - ? 1 + ReferenceDepth(((SymbolicReference)reference).Target) - : 1; + ? 1 + ReferenceDepth(((SymbolicReference)reference).Target) + : 1; } } } diff --git a/LibGit2Sharp/Core/LambdaEqualityHelper.cs b/LibGit2Sharp/Core/LambdaEqualityHelper.cs index 120e705d..80e826c0 100644 --- a/LibGit2Sharp/Core/LambdaEqualityHelper.cs +++ b/LibGit2Sharp/Core/LambdaEqualityHelper.cs @@ -48,7 +48,7 @@ namespace LibGit2Sharp.Core foreach (Func<T, object> accessor in equalityContributorAccessors) { object item = accessor(instance); - hashCode = (hashCode*397) ^ (item != null ? item.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (item != null ? item.GetHashCode() : 0); } } diff --git a/LibGit2Sharp/Core/LazyGroup.cs b/LibGit2Sharp/Core/LazyGroup.cs index da6fed92..d8b13fa4 100644 --- a/LibGit2Sharp/Core/LazyGroup.cs +++ b/LibGit2Sharp/Core/LazyGroup.cs @@ -94,8 +94,7 @@ namespace LibGit2Sharp.Core { public LazyWrapper(Func<TType> evaluator) : base(evaluator) - { - } + { } } } } diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index 2590669b..e637a0eb 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -249,7 +249,7 @@ namespace LibGit2Sharp.Core [MarshalAs(UnmanagedType.LPArray)] [In] IntPtr[] parents); [DllImport(libgit2)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] internal static extern string git_commit_message(GitObjectSafeHandle commit); [DllImport(libgit2)] @@ -277,7 +277,7 @@ namespace LibGit2Sharp.Core [DllImport(libgit2)] internal static extern int git_config_delete_multivar( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (StrictUtf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string regexp); [DllImport(libgit2)] @@ -401,8 +401,8 @@ namespace LibGit2Sharp.Core [DllImport(libgit2)] internal static extern int git_cred_userpass_plaintext_new( out IntPtr cred, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (StrictUtf8Marshaler))] string username, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (StrictUtf8Marshaler))] string password); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string username, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string password); [DllImport(libgit2)] internal static extern int git_describe_commit( @@ -538,7 +538,7 @@ namespace LibGit2Sharp.Core [DllImport(libgit2)] internal static extern int git_ignore_add_rule( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (StrictUtf8Marshaler))] string rules); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string rules); [DllImport(libgit2)] internal static extern int git_ignore_clear_internal_rules(RepositorySafeHandle repo); @@ -953,7 +953,7 @@ namespace LibGit2Sharp.Core [DllImport(libgit2)] internal static extern int git_reference_ensure_log( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (StrictUtf8Marshaler))] string refname); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string refname); [DllImport(libgit2)] internal static extern void git_reflog_free( diff --git a/LibGit2Sharp/Core/PathCase.cs b/LibGit2Sharp/Core/PathCase.cs index a5fadbb4..600f693d 100644 --- a/LibGit2Sharp/Core/PathCase.cs +++ b/LibGit2Sharp/Core/PathCase.cs @@ -16,6 +16,7 @@ namespace LibGit2Sharp.Core comparer = StringComparer.OrdinalIgnoreCase; comparison = StringComparison.OrdinalIgnoreCase; break; + default: comparer = StringComparer.Ordinal; comparison = StringComparison.Ordinal; diff --git a/LibGit2Sharp/Core/Platform.cs b/LibGit2Sharp/Core/Platform.cs index debdc73a..d18613d2 100644 --- a/LibGit2Sharp/Core/Platform.cs +++ b/LibGit2Sharp/Core/Platform.cs @@ -13,10 +13,7 @@ namespace LibGit2Sharp.Core { public static string ProcessorArchitecture { - get - { - return Environment.Is64BitProcess ? "amd64" : "x86"; - } + get { return Environment.Is64BitProcess ? "amd64" : "x86"; } } public static OperatingSystemType OperatingSystem @@ -29,8 +26,10 @@ namespace LibGit2Sharp.Core case 4: case 128: return OperatingSystemType.Unix; + case 6: return OperatingSystemType.MacOSX; + default: return OperatingSystemType.Windows; } diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index c18c3bfe..5c91f392 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -172,7 +172,7 @@ namespace LibGit2Sharp.Core return new RawContentStream(handle, NativeMethods.git_blob_rawcontent, h => size); } - public static Int64 git_blob_rawsize(GitObjectSafeHandle obj) + public static long git_blob_rawsize(GitObjectSafeHandle obj) { return NativeMethods.git_blob_rawsize(obj); } @@ -210,21 +210,19 @@ namespace LibGit2Sharp.Core public static IEnumerable<Branch> git_branch_iterator(Repository repo, GitBranchType branchType) { - return git_iterator( - (out BranchIteratorSafeHandle iter_out) => - NativeMethods.git_branch_iterator_new(out iter_out, repo.Handle, branchType), - (BranchIteratorSafeHandle iter, out ReferenceSafeHandle ref_out, out int res) => - { - GitBranchType type_out; - res = NativeMethods.git_branch_next(out ref_out, out type_out, iter); - return new { BranchType = type_out }; - }, - (handle, payload) => - { - var reference = Reference.BuildFromPtr<Reference>(handle, repo); - return new Branch(repo, reference, reference.CanonicalName); - } - ); + return git_iterator((out BranchIteratorSafeHandle iter_out) => + NativeMethods.git_branch_iterator_new(out iter_out, repo.Handle, branchType), + (BranchIteratorSafeHandle iter, out ReferenceSafeHandle ref_out, out int res) => + { + GitBranchType type_out; + res = NativeMethods.git_branch_next(out ref_out, out type_out, iter); + return new { BranchType = type_out }; + }, + (handle, payload) => + { + var reference = Reference.BuildFromPtr<Reference>(handle, repo); + return new Branch(repo, reference, reference.CanonicalName); + }); } public static void git_branch_iterator_free(IntPtr iter) @@ -361,10 +359,16 @@ namespace LibGit2Sharp.Core var treeOid = tree.Id.Oid; - int res = NativeMethods.git_commit_create_from_ids( - out commitOid, repo, referenceName, authorHandle, - committerHandle, null, message, - ref treeOid, (UIntPtr)parentPtrs.Count, parentPtrs.ToArray()); + int res = NativeMethods.git_commit_create_from_ids(out commitOid, + repo, + referenceName, + authorHandle, + committerHandle, + null, + message, + ref treeOid, + (UIntPtr)parentPtrs.Count, + parentPtrs.ToArray()); Ensure.ZeroResult(res); @@ -502,8 +506,8 @@ namespace LibGit2Sharp.Core } return new ConfigurationEntry<T>(LaxUtf8Marshaler.FromNative(entry.namePtr), - (T)configurationParser[typeof(T)](LaxUtf8Marshaler.FromNative(entry.valuePtr)), - (ConfigurationLevel)entry.level); + (T)configurationParser[typeof(T)](LaxUtf8Marshaler.FromNative(entry.valuePtr)), + (ConfigurationLevel)entry.level); } public static ConfigurationSafeHandle git_config_new() @@ -593,19 +597,18 @@ namespace LibGit2Sharp.Core string regexp, Func<IntPtr, ConfigurationEntry<string>> resultSelector) { - return git_iterator( - (out ConfigurationIteratorSafeHandle iter) => - NativeMethods.git_config_iterator_glob_new(out iter, config, regexp), - (ConfigurationIteratorSafeHandle iter, out SafeHandleBase handle, out int res) => - { - handle = null; + return git_iterator((out ConfigurationIteratorSafeHandle iter) => + NativeMethods.git_config_iterator_glob_new(out iter, config, regexp), + (ConfigurationIteratorSafeHandle iter, out SafeHandleBase handle, out int res) => + { + handle = null; - IntPtr entry; - res = NativeMethods.git_config_next(out entry, iter); - return new { EntryPtr = entry }; - }, - (handle, payload) => resultSelector(payload.EntryPtr) - ); + IntPtr entry; + res = NativeMethods.git_config_next(out entry, iter); + return new { EntryPtr = entry }; + }, + (handle, payload) => + resultSelector(payload.EntryPtr)); } public static void git_config_iterator_free(IntPtr iter) @@ -631,8 +634,7 @@ namespace LibGit2Sharp.Core ObjectId committishId, DescribeOptions options) { - Ensure.ArgumentPositiveInt32(options.MinimumCommitIdAbbreviatedSize, - "options.MinimumCommitIdAbbreviatedSize"); + Ensure.ArgumentPositiveInt32(options.MinimumCommitIdAbbreviatedSize, "options.MinimumCommitIdAbbreviatedSize"); using (var osw = new ObjectSafeWrapper(committishId, repo)) { @@ -699,9 +701,16 @@ namespace LibGit2Sharp.Core using (var osw1 = new ObjectSafeWrapper(oldBlob, repo, true)) using (var osw2 = new ObjectSafeWrapper(newBlob, repo, true)) { - int res = NativeMethods.git_diff_blobs( - osw1.ObjectPtr, null, osw2.ObjectPtr, null, - options, fileCallback, null, hunkCallback, lineCallback, IntPtr.Zero); + int res = NativeMethods.git_diff_blobs(osw1.ObjectPtr, + null, + osw2.ObjectPtr, + null, + options, + fileCallback, + null, + hunkCallback, + lineCallback, + IntPtr.Zero); Ensure.ZeroResult(res); } @@ -913,8 +922,11 @@ namespace LibGit2Sharp.Core { IndexEntrySafeHandle ancestor, ours, theirs; - int res = NativeMethods.git_index_conflict_get( - out ancestor, out ours, out theirs, index, path); + int res = NativeMethods.git_index_conflict_get(out ancestor, + out ours, + out theirs, + index, + path); if (res == (int)GitErrorCode.NotFound) { @@ -923,10 +935,9 @@ namespace LibGit2Sharp.Core Ensure.ZeroResult(res); - return new Conflict( - IndexEntry.BuildFromPtr(ancestor), - IndexEntry.BuildFromPtr(ours), - IndexEntry.BuildFromPtr(theirs)); + return new Conflict(IndexEntry.BuildFromPtr(ancestor), + IndexEntry.BuildFromPtr(ours), + IndexEntry.BuildFromPtr(theirs)); } public static ConflictIteratorSafeHandle git_index_conflict_iterator_new(IndexSafeHandle index) @@ -955,10 +966,9 @@ namespace LibGit2Sharp.Core using (ours) using (theirs) { - return new Conflict( - IndexEntry.BuildFromPtr(ancestor), - IndexEntry.BuildFromPtr(ours), - IndexEntry.BuildFromPtr(theirs)); + return new Conflict(IndexEntry.BuildFromPtr(ancestor), + IndexEntry.BuildFromPtr(ours), + IndexEntry.BuildFromPtr(theirs)); } } @@ -1183,12 +1193,11 @@ namespace LibGit2Sharp.Core { IntPtr[] their_heads = heads.Select(head => head.DangerousGetHandle()).ToArray(); - int res = NativeMethods.git_merge( - repo, - their_heads, - (UIntPtr)their_heads.Length, - ref mergeOptions, - ref checkoutOptions); + int res = NativeMethods.git_merge(repo, + their_heads, + (UIntPtr)their_heads.Length, + ref mergeOptions, + ref checkoutOptions); Ensure.ZeroResult(res); } @@ -1201,12 +1210,11 @@ namespace LibGit2Sharp.Core { IntPtr[] their_heads = heads.Select(head => head.DangerousGetHandle()).ToArray(); - int res = NativeMethods.git_merge_analysis( - out analysis_out, - out preference_out, - repo, - their_heads, - their_heads.Length); + int res = NativeMethods.git_merge_analysis(out analysis_out, + out preference_out, + repo, + their_heads, + their_heads.Length); Ensure.ZeroResult(res); } @@ -1281,8 +1289,10 @@ namespace LibGit2Sharp.Core public static ICollection<TResult> git_note_foreach<TResult>(RepositorySafeHandle repo, string notes_ref, Func<GitOid, GitOid, TResult> resultSelector) { - return git_foreach(resultSelector, c => NativeMethods.git_note_foreach(repo, notes_ref, - (ref GitOid x, ref GitOid y, IntPtr p) => c(x, y, p), IntPtr.Zero)); + return git_foreach(resultSelector, c => NativeMethods.git_note_foreach(repo, + notes_ref, + (ref GitOid x, ref GitOid y, IntPtr p) => c(x, y, p), + IntPtr.Zero)); } public static void git_note_free(IntPtr note) @@ -1424,7 +1434,8 @@ namespace LibGit2Sharp.Core throw new LibGit2SharpException(String.Format(CultureInfo.InvariantCulture, "Unable to allocate {0} bytes; out of memory", len), - GitErrorCode.Error, GitErrorCategory.NoMemory); + GitErrorCode.Error, + GitErrorCategory.NoMemory); } return toReturn; @@ -1456,12 +1467,10 @@ namespace LibGit2Sharp.Core ObjectDatabaseSafeHandle odb, Func<IntPtr, TResult> resultSelector) { - return git_foreach( - resultSelector, - c => NativeMethods.git_odb_foreach( - odb, - (x, p) => c(x, p), - IntPtr.Zero)); + return git_foreach(resultSelector, + c => NativeMethods.git_odb_foreach(odb, + (x, p) => c(x, p), + IntPtr.Zero)); } public static OdbStreamSafeHandle git_odb_open_wstream(ObjectDatabaseSafeHandle odb, long size, GitObjectType type) @@ -1541,7 +1550,11 @@ namespace LibGit2Sharp.Core #region git_reference_ - public static ReferenceSafeHandle git_reference_create(RepositorySafeHandle repo, string name, ObjectId targetId, bool allowOverwrite, + public static ReferenceSafeHandle git_reference_create( + RepositorySafeHandle repo, + string name, + ObjectId targetId, + bool allowOverwrite, string logMessage) { GitOid oid = targetId.Oid; @@ -1553,7 +1566,11 @@ namespace LibGit2Sharp.Core return handle; } - public static ReferenceSafeHandle git_reference_symbolic_create(RepositorySafeHandle repo, string name, string target, bool allowOverwrite, + public static ReferenceSafeHandle git_reference_symbolic_create( + RepositorySafeHandle repo, + string name, + string target, + bool allowOverwrite, string logMessage) { ReferenceSafeHandle handle; @@ -1633,7 +1650,10 @@ namespace LibGit2Sharp.Core return NativeMethods.git_reference_target(reference).MarshalAsObjectId(); } - public static ReferenceSafeHandle git_reference_rename(ReferenceSafeHandle reference, string newName, bool allowOverwrite, + public static ReferenceSafeHandle git_reference_rename( + ReferenceSafeHandle reference, + string newName, + bool allowOverwrite, string logMessage) { ReferenceSafeHandle ref_out; @@ -2026,16 +2046,14 @@ namespace LibGit2Sharp.Core try { - int res = NativeMethods.git_remote_rename( - ref array.Array, - repo, - name, - new_name); + int res = NativeMethods.git_remote_rename(ref array.Array, + repo, + name, + new_name); if (res == (int)GitErrorCode.NotFound) { - throw new NotFoundException( - string.Format("Remote '{0}' does not exist and cannot be renamed.", name)); + throw new NotFoundException(string.Format("Remote '{0}' does not exist and cannot be renamed.", name)); } Ensure.ZeroResult(res); @@ -2084,13 +2102,12 @@ namespace LibGit2Sharp.Core RepositorySafeHandle repo, Func<string, string, GitOid, bool, TResult> resultSelector) { - return git_foreach( - resultSelector, - c => NativeMethods.git_repository_fetchhead_foreach( - repo, - (IntPtr w, IntPtr x, ref GitOid y, bool z, IntPtr p) - => c(LaxUtf8Marshaler.FromNative(w), LaxUtf8Marshaler.FromNative(x), y, z, p), IntPtr.Zero), - GitErrorCode.NotFound); + return git_foreach(resultSelector, + c => NativeMethods.git_repository_fetchhead_foreach(repo, + (IntPtr w, IntPtr x, ref GitOid y, bool z, IntPtr p) + => c(LaxUtf8Marshaler.FromNative(w), LaxUtf8Marshaler.FromNative(x), y, z, p), + IntPtr.Zero), + GitErrorCode.NotFound); } public static void git_repository_free(IntPtr repo) @@ -2147,11 +2164,10 @@ namespace LibGit2Sharp.Core RepositorySafeHandle repo, Func<GitOid, TResult> resultSelector) { - return git_foreach( - resultSelector, - c => NativeMethods.git_repository_mergehead_foreach( - repo, (ref GitOid x, IntPtr p) => c(x, p), IntPtr.Zero), - GitErrorCode.NotFound); + return git_foreach(resultSelector, + c => NativeMethods.git_repository_mergehead_foreach(repo, + (ref GitOid x, IntPtr p) => c(x, p), IntPtr.Zero), + GitErrorCode.NotFound); } public static string git_repository_message(RepositorySafeHandle repo) @@ -2186,7 +2202,8 @@ namespace LibGit2Sharp.Core if (res == (int)GitErrorCode.NotFound) { throw new RepositoryNotFoundException(String.Format(CultureInfo.InvariantCulture, - "Path '{0}' doesn't point at a valid Git repository or workdir.", path)); + "Path '{0}' doesn't point at a valid Git repository or workdir.", + path)); } Ensure.ZeroResult(res); @@ -2216,7 +2233,8 @@ namespace LibGit2Sharp.Core if (res == (int)GitErrorCode.NotFound) { throw new RepositoryNotFoundException(String.Format(CultureInfo.InvariantCulture, - "Path '{0}' doesn't point at a valid Git repository or workdir.", path)); + "Path '{0}' doesn't point at a valid Git repository or workdir.", + path)); } Ensure.ZeroResult(res); @@ -2482,11 +2500,12 @@ namespace LibGit2Sharp.Core RepositorySafeHandle repo, Func<int, IntPtr, GitOid, TResult> resultSelector) { - return git_foreach( - resultSelector, - c => NativeMethods.git_stash_foreach( - repo, (UIntPtr i, IntPtr m, ref GitOid x, IntPtr p) => c((int)i, m, x, p), IntPtr.Zero), - GitErrorCode.NotFound); + return git_foreach(resultSelector, + c => NativeMethods.git_stash_foreach(repo, + (UIntPtr i, IntPtr m, ref GitOid x, IntPtr p) + => c((int)i, m, x, p), + IntPtr.Zero), + GitErrorCode.NotFound); } public static void git_stash_drop(RepositorySafeHandle repo, int index) @@ -2544,7 +2563,8 @@ namespace LibGit2Sharp.Core case (int)GitErrorCode.Ambiguous: 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().", + "You can either force a literal path evaluation " + + "(GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH), or use git_status_foreach().", path); default: diff --git a/LibGit2Sharp/Core/RawContentStream.cs b/LibGit2Sharp/Core/RawContentStream.cs index d02fe8b8..566eb585 100644 --- a/LibGit2Sharp/Core/RawContentStream.cs +++ b/LibGit2Sharp/Core/RawContentStream.cs @@ -64,5 +64,5 @@ namespace LibGit2Sharp.Core base.Dispose(disposing); Dispose(handle, linkedResources); } - } + } } diff --git a/LibGit2Sharp/Core/SubmoduleLazyGroup.cs b/LibGit2Sharp/Core/SubmoduleLazyGroup.cs index 0591574d..10df34a4 100644 --- a/LibGit2Sharp/Core/SubmoduleLazyGroup.cs +++ b/LibGit2Sharp/Core/SubmoduleLazyGroup.cs @@ -15,11 +15,13 @@ namespace LibGit2Sharp.Core protected override void EvaluateInternal(Action<SubmoduleSafeHandle> evaluator) { - repo.Submodules.Lookup(name, handle => - { - evaluator(handle); - return default(object); - }, true); + repo.Submodules.Lookup(name, + handle => + { + evaluator(handle); + return default(object); + }, + true); } } } diff --git a/LibGit2Sharp/Core/TarWriter.cs b/LibGit2Sharp/Core/TarWriter.cs index 9f71db44..ea236843 100644 --- a/LibGit2Sharp/Core/TarWriter.cs +++ b/LibGit2Sharp/Core/TarWriter.cs @@ -75,8 +75,21 @@ namespace LibGit2Sharp.Core WriteExtendedHeader(fileNameExtendedHeader, linkExtendedHeader, entrySha, modificationTime); // Note: in case of links, we won't add a content, but the size in the header will still be != 0. It seems strange, but it seem to be what git.git is doing? - WriteHeader(fileNameExtendedHeader.Name, fileNameExtendedHeader.Prefix, modificationTime, (data != null) ? data.Length : 0, mode, - userId, groupId, typeflag, linkExtendedHeader.Link, userName, groupName, deviceMajorNumber, deviceMinorNumber); + WriteHeader(fileNameExtendedHeader.Name, + fileNameExtendedHeader.Prefix, + modificationTime, + (data != null) + ? data.Length + : 0, + mode, + userId, + groupId, + typeflag, + linkExtendedHeader.Link, + userName, + groupName, + deviceMajorNumber, + deviceMinorNumber); // folders have no data, and so do links if (data != null && !isLink) @@ -94,7 +107,9 @@ namespace LibGit2Sharp.Core { int bytesRead = data.Read(buffer, 0, buffer.Length); if (bytesRead < 0) + { throw new IOException("TarWriter unable to read from provided stream"); + } dest.Write(buffer, 0, bytesRead); count -= bytesRead; @@ -103,7 +118,10 @@ namespace LibGit2Sharp.Core { int bytesRead = data.Read(buffer, 0, (int)count); if (bytesRead < 0) + { throw new IOException("TarWriter unable to read from provided stream"); + } + if (bytesRead == 0) { while (count > 0) @@ -113,7 +131,9 @@ namespace LibGit2Sharp.Core } } else + { dest.Write(buffer, 0, bytesRead); + } } } @@ -143,8 +163,19 @@ namespace LibGit2Sharp.Core string deviceMajorNumber, string deviceMinorNumber) { - var tarHeader = new UsTarHeader(fileName, namePrefix, lastModificationTime, count, mode, - userId, groupId, typeflag, link, userName, groupName, deviceMajorNumber, deviceMinorNumber); + var tarHeader = new UsTarHeader(fileName, + namePrefix, + lastModificationTime, + count, + mode, + userId, + groupId, + typeflag, + link, + userName, + groupName, + deviceMajorNumber, + deviceMinorNumber); var header = tarHeader.GetHeaderValue(); OutStream.Write(header, 0, header.Length); } @@ -168,7 +199,10 @@ namespace LibGit2Sharp.Core if (data.Length > 100) { return new LinkExtendedHeader(link, - string.Format(CultureInfo.InvariantCulture, "see %s.paxheader{0}", entrySha), true); + string.Format(CultureInfo.InvariantCulture, + "see %s.paxheader{0}", + entrySha), + true); } return new LinkExtendedHeader(link, link, false); @@ -198,8 +232,20 @@ namespace LibGit2Sharp.Core using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(extHeader))) { - Write(string.Format(CultureInfo.InvariantCulture, "{0}.paxheader", entrySha), stream, modificationTime, "666".OctalToInt32(), - "0", "0", 'x', "root", "root", "0", "0", entrySha, false); + Write(string.Format(CultureInfo.InvariantCulture, + "{0}.paxheader", + entrySha), + stream, modificationTime, + "666".OctalToInt32(), + "0", + "0", + 'x', + "root", + "root", + "0", + "0", + entrySha, + false); } } @@ -208,7 +254,9 @@ namespace LibGit2Sharp.Core // "%u %s=%s\n" int len = key.Length + value.Length + 3; for (int i = len; i > 9; i /= 10) + { len++; + } return string.Format(CultureInfo.InvariantCulture, "{0} {1}={2}\n", len, key, value); } @@ -410,8 +458,12 @@ 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(CultureInfo.InvariantCulture, "{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 0080bc4c..17ee637f 100644 --- a/LibGit2Sharp/Core/Utf8Marshaler.cs +++ b/LibGit2Sharp/Core/Utf8Marshaler.cs @@ -27,8 +27,7 @@ namespace LibGit2Sharp.Core #region ICustomMarshaler public override void CleanUpNativeData(IntPtr pNativeData) - { - } + { } #endregion } @@ -70,8 +69,9 @@ namespace LibGit2Sharp.Core public override Object MarshalNativeToManaged(IntPtr pNativeData) { - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, "{0} cannot be used to retrieve data from libgit2.", GetType().Name)); + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, + "{0} cannot be used to retrieve data from libgit2.", + GetType().Name)); } #endregion @@ -105,8 +105,9 @@ namespace LibGit2Sharp.Core public override IntPtr MarshalManagedToNative(object managedObj) { - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, "{0} cannot be used to pass data to libgit2.", GetType().Name)); + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, + "{0} cannot be used to pass data to libgit2.", + GetType().Name)); } #endregion diff --git a/LibGit2Sharp/Core/WriteStream.cs b/LibGit2Sharp/Core/WriteStream.cs index 37db8af8..4b7fb03c 100644 --- a/LibGit2Sharp/Core/WriteStream.cs +++ b/LibGit2Sharp/Core/WriteStream.cs @@ -29,8 +29,7 @@ namespace LibGit2Sharp.Core public override long Length { get { throw new InvalidOperationException(); } } public override void Flush() - { - } + { } public override void SetLength(long value) { |