From 97256e7e208df939463ecab82f5b1484893d8b63 Mon Sep 17 00:00:00 2001 From: J Wyman Date: Mon, 15 Jun 2015 15:47:00 -0700 Subject: Applying consistant formatting across the project Cleaning up white space usage Cleaning up `using` statements Cleaning up `cref` usage Cleaning up parameter alignment Cleaning up brace positioning --- LibGit2Sharp/AmbiguousSpecificationException.cs | 12 +- LibGit2Sharp/BareRepositoryException.cs | 15 +- LibGit2Sharp/BlameHunk.cs | 4 +- LibGit2Sharp/BlameHunkCollection.cs | 2 + LibGit2Sharp/Branch.cs | 12 +- LibGit2Sharp/BranchCollection.cs | 15 +- LibGit2Sharp/BranchUpdater.cs | 3 +- LibGit2Sharp/CheckoutConflictException.cs | 15 +- LibGit2Sharp/CheckoutOptions.cs | 5 +- LibGit2Sharp/CherryPickOptions.cs | 3 +- LibGit2Sharp/CloneOptions.cs | 6 +- LibGit2Sharp/Commit.cs | 4 +- LibGit2Sharp/CommitFilter.cs | 12 +- LibGit2Sharp/CommitLog.cs | 5 +- LibGit2Sharp/CommitRewriteInfo.cs | 29 ++-- LibGit2Sharp/Configuration.cs | 35 ++-- LibGit2Sharp/ConfigurationEntry.cs | 3 +- LibGit2Sharp/ConflictCollection.cs | 8 +- LibGit2Sharp/ContentChanges.cs | 9 +- LibGit2Sharp/Core/EncodingMarshaler.cs | 5 +- LibGit2Sharp/Core/Ensure.cs | 4 +- LibGit2Sharp/Core/FileHistory.cs | 7 +- LibGit2Sharp/Core/FilePath.cs | 4 +- LibGit2Sharp/Core/FilePathMarshaler.cs | 5 +- LibGit2Sharp/Core/GitBlame.cs | 7 +- LibGit2Sharp/Core/GitCheckoutOptsWrapper.cs | 3 + LibGit2Sharp/Core/GitFilter.cs | 17 +- LibGit2Sharp/Core/GitObjectLazyGroup.cs | 2 + LibGit2Sharp/Core/GitObjectType.cs | 10 +- LibGit2Sharp/Core/GitOdbBackendStream.cs | 7 +- LibGit2Sharp/Core/GitRepositoryInitOptions.cs | 8 +- LibGit2Sharp/Core/GitRevertOpts.cs | 2 +- LibGit2Sharp/Core/GitSmartSubtransportStream.cs | 3 +- LibGit2Sharp/Core/GitWriteStream.cs | 2 +- LibGit2Sharp/Core/HistoryRewriter.cs | 47 +++-- LibGit2Sharp/Core/LambdaEqualityHelper.cs | 2 +- LibGit2Sharp/Core/LazyGroup.cs | 3 +- LibGit2Sharp/Core/NativeMethods.cs | 12 +- LibGit2Sharp/Core/PathCase.cs | 1 + LibGit2Sharp/Core/Platform.cs | 7 +- LibGit2Sharp/Core/Proxy.cs | 220 +++++++++++++----------- LibGit2Sharp/Core/RawContentStream.cs | 2 +- LibGit2Sharp/Core/SubmoduleLazyGroup.cs | 12 +- LibGit2Sharp/Core/TarWriter.cs | 70 +++++++- LibGit2Sharp/Core/Utf8Marshaler.cs | 13 +- LibGit2Sharp/Core/WriteStream.cs | 3 +- LibGit2Sharp/DetachedHead.cs | 3 +- LibGit2Sharp/Diff.cs | 58 ++++--- LibGit2Sharp/EmptyCommitException.cs | 12 +- LibGit2Sharp/EntryExistsException.cs | 15 +- LibGit2Sharp/FetchHead.cs | 19 +- LibGit2Sharp/FetchOptionsBase.cs | 3 +- LibGit2Sharp/FilteringOptions.cs | 2 +- LibGit2Sharp/FollowFilter.cs | 5 +- LibGit2Sharp/GitLink.cs | 3 +- LibGit2Sharp/GitObject.cs | 16 +- LibGit2Sharp/GlobalSettings.cs | 7 +- LibGit2Sharp/HistoryDivergence.cs | 5 +- LibGit2Sharp/IRepository.cs | 2 +- LibGit2Sharp/Index.cs | 22 +-- LibGit2Sharp/IndexEntry.cs | 19 +- LibGit2Sharp/IndexNameEntry.cs | 20 ++- LibGit2Sharp/IndexReucEntry.cs | 12 +- LibGit2Sharp/InvalidSpecificationException.cs | 15 +- LibGit2Sharp/LibGit2SharpException.cs | 13 +- LibGit2Sharp/LockedFileException.cs | 15 +- LibGit2Sharp/LogConfiguration.cs | 3 +- LibGit2Sharp/MergeConflictException.cs | 3 +- LibGit2Sharp/MergeFetchHeadNotFoundException.cs | 12 +- LibGit2Sharp/MergeHead.cs | 3 +- LibGit2Sharp/MergeOptions.cs | 3 +- LibGit2Sharp/MergeTreeOptions.cs | 3 +- LibGit2Sharp/MergeTreeResult.cs | 18 +- LibGit2Sharp/NameConflictException.cs | 15 +- LibGit2Sharp/Network.cs | 84 +++++---- LibGit2Sharp/NonFastForwardException.cs | 15 +- LibGit2Sharp/NotFoundException.cs | 15 +- LibGit2Sharp/Note.cs | 12 +- LibGit2Sharp/NoteCollection.cs | 13 +- LibGit2Sharp/ObjectDatabase.cs | 33 ++-- LibGit2Sharp/ObjectId.cs | 8 +- LibGit2Sharp/OdbBackend.cs | 23 +-- LibGit2Sharp/OdbBackendStream.cs | 43 ++--- LibGit2Sharp/Patch.cs | 10 +- LibGit2Sharp/PatchStats.cs | 8 +- LibGit2Sharp/PeelException.cs | 15 +- LibGit2Sharp/PushResult.cs | 10 +- LibGit2Sharp/RecurseSubmodulesException.cs | 3 +- LibGit2Sharp/RefSpec.cs | 3 +- LibGit2Sharp/RefSpecCollection.cs | 3 +- LibGit2Sharp/Reference.cs | 4 +- LibGit2Sharp/ReferenceCollection.cs | 29 ++-- LibGit2Sharp/ReferenceWrapper.cs | 6 +- LibGit2Sharp/ReflogCollection.cs | 3 +- LibGit2Sharp/Remote.cs | 16 +- LibGit2Sharp/RemoteCallbacks.cs | 7 +- LibGit2Sharp/RemoteCollection.cs | 3 +- LibGit2Sharp/RemoteUpdater.cs | 15 +- LibGit2Sharp/RemoveFromIndexException.cs | 12 +- LibGit2Sharp/RenameDetails.cs | 8 +- LibGit2Sharp/Repository.cs | 96 +++++------ LibGit2Sharp/RepositoryExtensions.cs | 3 +- LibGit2Sharp/RepositoryNotFoundException.cs | 12 +- LibGit2Sharp/RepositoryOperationContext.cs | 12 +- LibGit2Sharp/RepositoryStatus.cs | 59 ++++--- LibGit2Sharp/RevertOptions.cs | 3 +- LibGit2Sharp/SmartSubtransport.cs | 3 +- LibGit2Sharp/SmartSubtransportRegistration.cs | 18 +- LibGit2Sharp/SmartSubtransportStream.cs | 38 ++-- LibGit2Sharp/StashCollection.cs | 19 +- LibGit2Sharp/StatusEntry.cs | 5 +- LibGit2Sharp/Submodule.cs | 3 +- LibGit2Sharp/SubmoduleCollection.cs | 39 ++--- LibGit2Sharp/SymbolicReference.cs | 9 +- LibGit2Sharp/Tag.cs | 3 +- LibGit2Sharp/TagAnnotation.cs | 8 +- LibGit2Sharp/TagCollection.cs | 3 +- LibGit2Sharp/TarArchiver.cs | 84 +++++++-- LibGit2Sharp/TransferProgress.cs | 25 +-- LibGit2Sharp/Tree.cs | 4 +- LibGit2Sharp/TreeChanges.cs | 30 ++-- LibGit2Sharp/TreeDefinition.cs | 13 +- LibGit2Sharp/TreeEntry.cs | 7 +- LibGit2Sharp/TreeEntryChanges.cs | 7 +- LibGit2Sharp/TreeEntryDefinition.cs | 59 ++++--- LibGit2Sharp/TreeEntryTargetType.cs | 5 +- LibGit2Sharp/UnbornBranchException.cs | 15 +- LibGit2Sharp/UnmatchedPathException.cs | 12 +- LibGit2Sharp/UnmergedIndexEntriesException.cs | 15 +- LibGit2Sharp/UserCanceledException.cs | 15 +- LibGit2Sharp/Version.cs | 20 +-- 131 files changed, 1044 insertions(+), 1002 deletions(-) diff --git a/LibGit2Sharp/AmbiguousSpecificationException.cs b/LibGit2Sharp/AmbiguousSpecificationException.cs index ec6352b6..577b84f1 100644 --- a/LibGit2Sharp/AmbiguousSpecificationException.cs +++ b/LibGit2Sharp/AmbiguousSpecificationException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public AmbiguousSpecificationException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public AmbiguousSpecificationException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -44,8 +42,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public AmbiguousSpecificationException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -54,7 +51,6 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected AmbiguousSpecificationException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } } } diff --git a/LibGit2Sharp/BareRepositoryException.cs b/LibGit2Sharp/BareRepositoryException.cs index 00b61a04..33c25f12 100644 --- a/LibGit2Sharp/BareRepositoryException.cs +++ b/LibGit2Sharp/BareRepositoryException.cs @@ -15,8 +15,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public BareRepositoryException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -24,8 +23,7 @@ namespace LibGit2Sharp /// A message that describes the error. public BareRepositoryException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -34,8 +32,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public BareRepositoryException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -44,12 +41,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected BareRepositoryException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal BareRepositoryException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/BlameHunk.cs b/LibGit2Sharp/BlameHunk.cs index 79dbf394..93d711c7 100644 --- a/LibGit2Sharp/BlameHunk.cs +++ b/LibGit2Sharp/BlameHunk.cs @@ -40,6 +40,7 @@ namespace LibGit2Sharp { FinalSignature = new Signature(Proxy.git_signature_dup(rawHunk.FinalSignature)); } + if (rawHunk.OrigSignature != IntPtr.Zero) { InitialSignature = new Signature(Proxy.git_signature_dup(rawHunk.OrigSignature)); @@ -49,7 +50,8 @@ namespace LibGit2Sharp /// /// For easier mocking /// - protected BlameHunk() { } + protected BlameHunk() + { } /// /// Determine if this hunk contains a given line. diff --git a/LibGit2Sharp/BlameHunkCollection.cs b/LibGit2Sharp/BlameHunkCollection.cs index f487915c..35b94552 100644 --- a/LibGit2Sharp/BlameHunkCollection.cs +++ b/LibGit2Sharp/BlameHunkCollection.cs @@ -31,10 +31,12 @@ namespace LibGit2Sharp MinLine = (uint)options.MinLine, MaxLine = (uint)options.MaxLine, }; + if (options.StartingAt != null) { rawopts.NewestCommit = repo.Committish(options.StartingAt).Oid; } + if (options.StoppingAt != null) { rawopts.OldestCommit = repo.Committish(options.StoppingAt).Oid; diff --git a/LibGit2Sharp/Branch.cs b/LibGit2Sharp/Branch.cs index bb8c45c6..905d9413 100644 --- a/LibGit2Sharp/Branch.cs +++ b/LibGit2Sharp/Branch.cs @@ -25,8 +25,7 @@ namespace LibGit2Sharp /// The full name of the reference internal Branch(Repository repo, Reference reference, string canonicalName) : this(repo, reference, _ => canonicalName) - { - } + { } /// /// Initializes a new instance of an orphaned class. @@ -38,8 +37,7 @@ namespace LibGit2Sharp /// The reference. internal Branch(Repository repo, Reference reference) : this(repo, reference, r => r.TargetIdentifier) - { - } + { } private Branch(Repository repo, Reference reference, Func canonicalNameSelector) : base(repo, reference, canonicalNameSelector) @@ -264,9 +262,9 @@ namespace LibGit2Sharp return CanonicalName.Substring(Reference.RemoteTrackingBranchPrefix.Length); } - throw new ArgumentException( - string.Format(CultureInfo.InvariantCulture, - "'{0}' does not look like a valid branch name.", CanonicalName)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, + "'{0}' does not look like a valid branch name.", + CanonicalName)); } } } diff --git a/LibGit2Sharp/BranchCollection.cs b/LibGit2Sharp/BranchCollection.cs index df38d241..5bb21c9a 100644 --- a/LibGit2Sharp/BranchCollection.cs +++ b/LibGit2Sharp/BranchCollection.cs @@ -92,7 +92,8 @@ namespace LibGit2Sharp public virtual IEnumerator GetEnumerator() { return Proxy.git_branch_iterator(repo, GitBranchType.GIT_BRANCH_ALL) - .ToList().GetEnumerator(); + .ToList() + .GetEnumerator(); } /// @@ -154,7 +155,8 @@ namespace LibGit2Sharp Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(committish, "committish"); - using (Proxy.git_branch_create_from_annotated(repo.Handle, name, committish, allowOverwrite)) { } + using (Proxy.git_branch_create_from_annotated(repo.Handle, name, committish, allowOverwrite)) + { } var branch = this[ShortToLocalName(name)]; return branch; @@ -269,8 +271,7 @@ namespace LibGit2Sharp using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr(Reference.LocalBranchPrefix + branch.FriendlyName)) { using (Proxy.git_branch_move(referencePtr, newName, allowOverwrite)) - { - } + { } } var newBranch = this[newName]; @@ -304,11 +305,7 @@ namespace LibGit2Sharp private string DebuggerDisplay { - get - { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); - } + get { return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } } } diff --git a/LibGit2Sharp/BranchUpdater.cs b/LibGit2Sharp/BranchUpdater.cs index d1a5c39c..032bf6cf 100644 --- a/LibGit2Sharp/BranchUpdater.cs +++ b/LibGit2Sharp/BranchUpdater.cs @@ -189,7 +189,8 @@ namespace LibGit2Sharp else { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, - "'{0}' does not look like a valid canonical branch name.", canonicalName)); + "'{0}' does not look like a valid canonical branch name.", + canonicalName)); } } } diff --git a/LibGit2Sharp/CheckoutConflictException.cs b/LibGit2Sharp/CheckoutConflictException.cs index 9bd525ca..16a5654b 100644 --- a/LibGit2Sharp/CheckoutConflictException.cs +++ b/LibGit2Sharp/CheckoutConflictException.cs @@ -16,8 +16,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public CheckoutConflictException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -25,8 +24,7 @@ namespace LibGit2Sharp /// A message that describes the error. public CheckoutConflictException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -35,8 +33,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public CheckoutConflictException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -45,12 +42,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected CheckoutConflictException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal CheckoutConflictException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/CheckoutOptions.cs b/LibGit2Sharp/CheckoutOptions.cs index 9e297cd4..e95532cb 100644 --- a/LibGit2Sharp/CheckoutOptions.cs +++ b/LibGit2Sharp/CheckoutOptions.cs @@ -34,8 +34,9 @@ namespace LibGit2Sharp { get { - return CheckoutModifiers.HasFlag(CheckoutModifiers.Force) ? - CheckoutStrategy.GIT_CHECKOUT_FORCE : CheckoutStrategy.GIT_CHECKOUT_SAFE; + return CheckoutModifiers.HasFlag(CheckoutModifiers.Force) + ? CheckoutStrategy.GIT_CHECKOUT_FORCE + : CheckoutStrategy.GIT_CHECKOUT_SAFE; } } diff --git a/LibGit2Sharp/CherryPickOptions.cs b/LibGit2Sharp/CherryPickOptions.cs index 14aa0418..065e79bb 100644 --- a/LibGit2Sharp/CherryPickOptions.cs +++ b/LibGit2Sharp/CherryPickOptions.cs @@ -10,8 +10,7 @@ /// By default the cherry pick will be committed if there are no conflicts. /// public CherryPickOptions() - { - } + { } /// /// When cherry picking a merge commit, the parent number to consider as diff --git a/LibGit2Sharp/CloneOptions.cs b/LibGit2Sharp/CloneOptions.cs index 6b264e8a..8d260db7 100644 --- a/LibGit2Sharp/CloneOptions.cs +++ b/LibGit2Sharp/CloneOptions.cs @@ -54,9 +54,9 @@ namespace LibGit2Sharp { get { - return this.Checkout ? - CheckoutStrategy.GIT_CHECKOUT_SAFE : - CheckoutStrategy.GIT_CHECKOUT_NONE; + return this.Checkout + ? CheckoutStrategy.GIT_CHECKOUT_SAFE + : CheckoutStrategy.GIT_CHECKOUT_NONE; } } diff --git a/LibGit2Sharp/Commit.cs b/LibGit2Sharp/Commit.cs index 6ea9d060..40429cd0 100644 --- a/LibGit2Sharp/Commit.cs +++ b/LibGit2Sharp/Commit.cs @@ -118,7 +118,9 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0} {1}", Id.ToString(7), MessageShort); + "{0} {1}", + Id.ToString(7), + MessageShort); } } diff --git a/LibGit2Sharp/CommitFilter.cs b/LibGit2Sharp/CommitFilter.cs index 5021c126..114cb498 100644 --- a/LibGit2Sharp/CommitFilter.cs +++ b/LibGit2Sharp/CommitFilter.cs @@ -73,12 +73,12 @@ namespace LibGit2Sharp } var types = new[] - { - typeof(string), typeof(ObjectId), - typeof(Commit), typeof(TagAnnotation), - typeof(Tag), typeof(Branch), typeof(DetachedHead), - typeof(Reference), typeof(DirectReference), typeof(SymbolicReference) - }; + { + typeof(string), typeof(ObjectId), + typeof(Commit), typeof(TagAnnotation), + typeof(Tag), typeof(Branch), typeof(DetachedHead), + typeof(Reference), typeof(DirectReference), typeof(SymbolicReference) + }; if (types.Contains(obj.GetType())) { diff --git a/LibGit2Sharp/CommitLog.cs b/LibGit2Sharp/CommitLog.cs index a31df9e2..4349c0fd 100644 --- a/LibGit2Sharp/CommitLog.cs +++ b/LibGit2Sharp/CommitLog.cs @@ -22,8 +22,7 @@ namespace LibGit2Sharp /// The repository. internal CommitLog(Repository repo) : this(repo, new CommitFilter()) - { - } + { } /// /// Initializes a new instance of the class. @@ -103,7 +102,7 @@ namespace LibGit2Sharp Ensure.ArgumentNotNull(path, "path"); Ensure.ArgumentNotNull(filter, "filter"); - return new FileHistory(repo, path, new CommitFilter {SortBy = filter.SortBy}); + return new FileHistory(repo, path, new CommitFilter { SortBy = filter.SortBy }); } /// diff --git a/LibGit2Sharp/CommitRewriteInfo.cs b/LibGit2Sharp/CommitRewriteInfo.cs index a4387e83..ca739957 100644 --- a/LibGit2Sharp/CommitRewriteInfo.cs +++ b/LibGit2Sharp/CommitRewriteInfo.cs @@ -28,18 +28,18 @@ namespace LibGit2Sharp public static CommitRewriteInfo From(Commit commit) { return new CommitRewriteInfo - { - Author = commit.Author, - Committer = commit.Committer, - Message = commit.Message - }; + { + Author = commit.Author, + Committer = commit.Committer, + Message = commit.Message + }; } - /// - /// Build a from the passed in, - /// optionally overriding some of its properties - /// - /// The whose information is to be copied + /// + /// Build a from the passed in, + /// optionally overriding some of its properties + /// + /// The whose information is to be copied /// Optional override for the author /// A new object that matches the info for the /// with the optional parameters replaced.. @@ -85,10 +85,11 @@ namespace LibGit2Sharp /// Optional override for the message /// A new object that matches the info for the /// with the optional parameters replaced.. - public static CommitRewriteInfo From(Commit commit, - Signature author, - Signature committer, - string message) + public static CommitRewriteInfo From( + Commit commit, + Signature author, + Signature committer, + string message) { var cri = From(commit); cri.Author = author ?? cri.Author; diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs index 6880e8e6..69133fc9 100644 --- a/LibGit2Sharp/Configuration.cs +++ b/LibGit2Sharp/Configuration.cs @@ -28,8 +28,12 @@ namespace LibGit2Sharp protected Configuration() { } - internal Configuration(Repository repository, string repositoryConfigurationFileLocation, string globalConfigurationFileLocation, - string xdgConfigurationFileLocation, string systemConfigurationFileLocation) + internal Configuration( + Repository repository, + string repositoryConfigurationFileLocation, + string globalConfigurationFileLocation, + string xdgConfigurationFileLocation, + string systemConfigurationFileLocation) { if (repositoryConfigurationFileLocation != null) { @@ -120,8 +124,7 @@ namespace LibGit2Sharp /// /// Path to an existing Repository configuration file. /// An instance of . - public static Configuration BuildFrom( - string repositoryConfigurationFileLocation) + public static Configuration BuildFrom(string repositoryConfigurationFileLocation) { return BuildFrom(repositoryConfigurationFileLocation, null, null, null); } @@ -227,7 +230,7 @@ namespace LibGit2Sharp /// public virtual bool HasConfig(ConfigurationLevel level) { - using (ConfigurationSafeHandle snapshot = Snapshot ()) + using (ConfigurationSafeHandle snapshot = Snapshot()) using (ConfigurationSafeHandle handle = RetrieveConfigurationHandle(level, false, snapshot)) { return handle != null; @@ -690,9 +693,9 @@ namespace LibGit2Sharp if (handle == null && throwIfStoreHasNotBeenFound) { - throw new LibGit2SharpException( - string.Format(CultureInfo.InvariantCulture, "No {0} configuration file has been found.", - Enum.GetName(typeof(ConfigurationLevel), level))); + throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, + "No {0} configuration file has been found.", + Enum.GetName(typeof(ConfigurationLevel), level))); } return handle; @@ -765,14 +768,20 @@ namespace LibGit2Sharp { const string userNameKey = "user.name"; var name = this.GetValueOrDefault(userNameKey); - var normalizedName = NormalizeUserSetting(shouldThrowIfNotFound, userNameKey, name, - () => "unknown"); + var normalizedName = NormalizeUserSetting(shouldThrowIfNotFound, + userNameKey, + name, + () => "unknown"); const string userEmailKey = "user.email"; var email = this.GetValueOrDefault(userEmailKey); - var normalizedEmail = NormalizeUserSetting(shouldThrowIfNotFound, userEmailKey, email, - () => string.Format( - CultureInfo.InvariantCulture, "{0}@{1}", Environment.UserName, Environment.UserDomainName)); + var normalizedEmail = NormalizeUserSetting(shouldThrowIfNotFound, + userEmailKey, + email, + () => string.Format(CultureInfo.InvariantCulture, + "{0}@{1}", + Environment.UserName, + Environment.UserDomainName)); return new Signature(normalizedName, normalizedEmail, now); } diff --git a/LibGit2Sharp/ConfigurationEntry.cs b/LibGit2Sharp/ConfigurationEntry.cs index 7456be3c..13c153a2 100644 --- a/LibGit2Sharp/ConfigurationEntry.cs +++ b/LibGit2Sharp/ConfigurationEntry.cs @@ -48,8 +48,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "{0} = \"{1}\"", Key, Value); + return string.Format(CultureInfo.InvariantCulture, "{0} = \"{1}\"", Key, Value); } } } diff --git a/LibGit2Sharp/ConflictCollection.cs b/LibGit2Sharp/ConflictCollection.cs index 8cd72a3b..229f091a 100644 --- a/LibGit2Sharp/ConflictCollection.cs +++ b/LibGit2Sharp/ConflictCollection.cs @@ -102,10 +102,10 @@ namespace LibGit2Sharp theirs = entry; break; default: - throw new InvalidOperationException(string.Format( - CultureInfo.InvariantCulture, - "Entry '{0}' bears an unexpected StageLevel '{1}'", - entry.Path, entry.StageLevel)); + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, + "Entry '{0}' bears an unexpected StageLevel '{1}'", + entry.Path, + entry.StageLevel)); } } diff --git a/LibGit2Sharp/ContentChanges.cs b/LibGit2Sharp/ContentChanges.cs index e5d84503..c2c70361 100644 --- a/LibGit2Sharp/ContentChanges.cs +++ b/LibGit2Sharp/ContentChanges.cs @@ -25,7 +25,10 @@ namespace LibGit2Sharp Proxy.git_diff_blobs(repo.Handle, oldBlob != null ? oldBlob.Id : null, newBlob != null ? newBlob.Id : null, - options, FileCallback, HunkCallback, LineCallback); + options, + FileCallback, + HunkCallback, + LineCallback); } internal ContentChanges(bool isBinaryComparison) @@ -120,7 +123,9 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - @"{{+{0}, -{1}}}", LinesAdded, LinesDeleted); + @"{{+{0}, -{1}}}", + LinesAdded, + LinesDeleted); } } } 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. /// - 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. /// public delegate int git_filter_check_fn( - GitFilter gitFilter, IntPtr payload, IntPtr filterSource, IntPtr attributeValues); + GitFilter gitFilter, + IntPtr payload, + IntPtr filterSource, + IntPtr attributeValues); /// /// 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. /// 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); /// /// 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( - 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(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 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 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 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(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(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(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> 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 git_note_foreach(RepositorySafeHandle repo, string notes_ref, Func 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 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 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 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 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 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) { diff --git a/LibGit2Sharp/DetachedHead.cs b/LibGit2Sharp/DetachedHead.cs index 094d9d26..d934db2c 100644 --- a/LibGit2Sharp/DetachedHead.cs +++ b/LibGit2Sharp/DetachedHead.cs @@ -4,8 +4,7 @@ { internal DetachedHead(Repository repo, Reference reference) : base(repo, reference, "(no branch)") - { - } + { } protected override string Shorten() { diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs index 911e2425..d8e8830c 100644 --- a/LibGit2Sharp/Diff.cs +++ b/LibGit2Sharp/Diff.cs @@ -210,7 +210,7 @@ namespace LibGit2Sharp { Func builder; - if (!ChangesBuilders.TryGetValue(typeof (T), out builder)) + if (!ChangesBuilders.TryGetValue(typeof(T), out builder)) { throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unexpected type '{0}' passed to Compare. Supported values are either '{1}' or '{2}'.", @@ -228,15 +228,13 @@ namespace LibGit2Sharp { diffOptions |= DiffModifiers.DisablePathspecMatch; - if (explicitPathsOptions.ShouldFailOnUnmatchedPath || - explicitPathsOptions.OnUnmatchedPath != null) + if (explicitPathsOptions.ShouldFailOnUnmatchedPath || explicitPathsOptions.OnUnmatchedPath != null) { diffOptions |= DiffModifiers.IncludeUnmodified; } } - using (DiffSafeHandle diff = BuildDiffList(oldTreeId, newTreeId, comparer, - diffOptions, paths, explicitPathsOptions, compareOptions)) + using (DiffSafeHandle diff = BuildDiffList(oldTreeId, newTreeId, comparer, diffOptions, paths, explicitPathsOptions, compareOptions)) { return (T)builder(diff); } @@ -323,7 +321,7 @@ namespace LibGit2Sharp { Func builder; - if (!ChangesBuilders.TryGetValue(typeof (T), out builder)) + if (!ChangesBuilders.TryGetValue(typeof(T), out builder)) { throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unexpected type '{0}' passed to Compare. Supported values are either '{1}' or '{2}'.", @@ -343,15 +341,13 @@ namespace LibGit2Sharp { diffOptions |= DiffModifiers.DisablePathspecMatch; - if (explicitPathsOptions.ShouldFailOnUnmatchedPath || - explicitPathsOptions.OnUnmatchedPath != null) + if (explicitPathsOptions.ShouldFailOnUnmatchedPath || explicitPathsOptions.OnUnmatchedPath != null) { diffOptions |= DiffModifiers.IncludeUnmodified; } } - using (DiffSafeHandle diff = BuildDiffList(oldTreeId, null, comparer, - diffOptions, paths, explicitPathsOptions, compareOptions)) + using (DiffSafeHandle diff = BuildDiffList(oldTreeId, null, comparer, diffOptions, paths, explicitPathsOptions, compareOptions)) { return (T)builder(diff); } @@ -421,8 +417,7 @@ namespace LibGit2Sharp /// Can be either a if you are only interested in the list of files modified, added, ..., or /// a if you want the actual patch content for the whole diff and for individual files. /// A containing the changes between the working directory and the index. - public virtual T Compare(IEnumerable paths, bool includeUntracked, - ExplicitPathsOptions explicitPathsOptions) where T : class + public virtual T Compare(IEnumerable paths, bool includeUntracked, ExplicitPathsOptions explicitPathsOptions) where T : class { return Compare(includeUntracked ? DiffModifiers.IncludeUntracked : DiffModifiers.None, paths, explicitPathsOptions); } @@ -444,18 +439,24 @@ namespace LibGit2Sharp /// Can be either a if you are only interested in the list of files modified, added, ..., or /// a if you want the actual patch content for the whole diff and for individual files. /// A containing the changes between the working directory and the index. - public virtual T Compare(IEnumerable paths, bool includeUntracked, ExplicitPathsOptions explicitPathsOptions, + public virtual T Compare( + IEnumerable paths, + bool includeUntracked, + ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions) where T : class { return Compare(includeUntracked ? DiffModifiers.IncludeUntracked : DiffModifiers.None, paths, explicitPathsOptions, compareOptions); } - internal virtual T Compare(DiffModifiers diffOptions, IEnumerable paths = null, - ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null) where T : class + internal virtual T Compare( + DiffModifiers diffOptions, + IEnumerable paths = null, + ExplicitPathsOptions explicitPathsOptions = null, + CompareOptions compareOptions = null) where T : class { Func builder; - if (!ChangesBuilders.TryGetValue(typeof (T), out builder)) + if (!ChangesBuilders.TryGetValue(typeof(T), out builder)) { throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unexpected type '{0}' passed to Compare. Supported values are either '{1}' or '{2}'.", @@ -470,15 +471,13 @@ namespace LibGit2Sharp { diffOptions |= DiffModifiers.DisablePathspecMatch; - if (explicitPathsOptions.ShouldFailOnUnmatchedPath || - explicitPathsOptions.OnUnmatchedPath != null) + if (explicitPathsOptions.ShouldFailOnUnmatchedPath || explicitPathsOptions.OnUnmatchedPath != null) { diffOptions |= DiffModifiers.IncludeUnmodified; } } - using (DiffSafeHandle diff = BuildDiffList(null, null, comparer, - diffOptions, paths, explicitPathsOptions, compareOptions)) + using (DiffSafeHandle diff = BuildDiffList(null, null, comparer, diffOptions, paths, explicitPathsOptions, compareOptions)) { return (T)builder(diff); } @@ -523,8 +522,13 @@ namespace LibGit2Sharp return (oh, nh, o) => Proxy.git_diff_tree_to_index(repo.Handle, repo.Index.Handle, oh, o); } - private DiffSafeHandle BuildDiffList(ObjectId oldTreeId, ObjectId newTreeId, TreeComparisonHandleRetriever comparisonHandleRetriever, - DiffModifiers diffOptions, IEnumerable paths, ExplicitPathsOptions explicitPathsOptions, + private DiffSafeHandle BuildDiffList( + ObjectId oldTreeId, + ObjectId newTreeId, + TreeComparisonHandleRetriever comparisonHandleRetriever, + DiffModifiers diffOptions, + IEnumerable paths, + ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions) { var matchedPaths = new MatchedPathsAggregator(); @@ -556,8 +560,7 @@ namespace LibGit2Sharp private static void DetectRenames(DiffSafeHandle diffList, CompareOptions compareOptions) { var similarityOptions = (compareOptions == null) ? null : compareOptions.Similarity; - if (similarityOptions == null || - similarityOptions.RenameDetectionMode == RenameDetectionMode.Default) + if (similarityOptions == null || similarityOptions.RenameDetectionMode == RenameDetectionMode.Default) { Proxy.git_diff_find_similar(diffList, null); return; @@ -620,9 +623,10 @@ namespace LibGit2Sharp Proxy.git_diff_find_similar(diffList, opts); } - private static void DispatchUnmatchedPaths(ExplicitPathsOptions explicitPathsOptions, - IEnumerable filePaths, - IEnumerable matchedPaths) + private static void DispatchUnmatchedPaths( + ExplicitPathsOptions explicitPathsOptions, + IEnumerable filePaths, + IEnumerable matchedPaths) { List unmatchedPaths = (filePaths != null ? filePaths.Except(matchedPaths) : Enumerable.Empty()).ToList(); diff --git a/LibGit2Sharp/EmptyCommitException.cs b/LibGit2Sharp/EmptyCommitException.cs index aa54a5f3..88d43ed8 100644 --- a/LibGit2Sharp/EmptyCommitException.cs +++ b/LibGit2Sharp/EmptyCommitException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public EmptyCommitException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public EmptyCommitException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -33,8 +31,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public EmptyCommitException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -43,7 +40,6 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected EmptyCommitException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } } } diff --git a/LibGit2Sharp/EntryExistsException.cs b/LibGit2Sharp/EntryExistsException.cs index 9dff4d75..117cf4d8 100644 --- a/LibGit2Sharp/EntryExistsException.cs +++ b/LibGit2Sharp/EntryExistsException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public EntryExistsException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public EntryExistsException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -33,8 +31,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public EntryExistsException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -43,12 +40,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected EntryExistsException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal EntryExistsException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/FetchHead.cs b/LibGit2Sharp/FetchHead.cs index 75f12ae0..456abedc 100644 --- a/LibGit2Sharp/FetchHead.cs +++ b/LibGit2Sharp/FetchHead.cs @@ -15,11 +15,20 @@ namespace LibGit2Sharp protected FetchHead() { } - internal FetchHead(Repository repo, string remoteCanonicalName, - string url, ObjectId targetId, bool forMerge, int index) - : base(repo, new DirectReference( - string.Format(CultureInfo.InvariantCulture, "FETCH_HEAD[{0}]", index), - repo, targetId), r => r.CanonicalName) + internal FetchHead( + Repository repo, + string remoteCanonicalName, + string url, + ObjectId targetId, + bool forMerge, + int index) + : base(repo, + new DirectReference(string.Format(CultureInfo.InvariantCulture, + "FETCH_HEAD[{0}]", + index), + repo, + targetId), + r => r.CanonicalName) { Url = url; ForMerge = forMerge; diff --git a/LibGit2Sharp/FetchOptionsBase.cs b/LibGit2Sharp/FetchOptionsBase.cs index 7ad3673e..48328666 100644 --- a/LibGit2Sharp/FetchOptionsBase.cs +++ b/LibGit2Sharp/FetchOptionsBase.cs @@ -8,8 +8,7 @@ namespace LibGit2Sharp public abstract class FetchOptionsBase { internal FetchOptionsBase() - { - } + { } /// /// Handler for network transfer and indexing progress information. diff --git a/LibGit2Sharp/FilteringOptions.cs b/LibGit2Sharp/FilteringOptions.cs index f06d5a2a..22988e62 100644 --- a/LibGit2Sharp/FilteringOptions.cs +++ b/LibGit2Sharp/FilteringOptions.cs @@ -22,6 +22,6 @@ namespace LibGit2Sharp /// The path to "hint" to the filters will be used to apply /// attributes. /// - public string HintPath { get; private set; } + public string HintPath { get; private set; } } } diff --git a/LibGit2Sharp/FollowFilter.cs b/LibGit2Sharp/FollowFilter.cs index 7bd60708..22681ed1 100644 --- a/LibGit2Sharp/FollowFilter.cs +++ b/LibGit2Sharp/FollowFilter.cs @@ -45,9 +45,8 @@ namespace LibGit2Sharp { if (!AllowedSortStrategies.Contains(value)) { - throw new ArgumentException( - "Unsupported sort strategy. Only 'Topological', 'Time', or 'Topological | Time' are allowed.", - "value"); + throw new ArgumentException("Unsupported sort strategy. Only 'Topological', 'Time', or 'Topological | Time' are allowed.", + "value"); } _sortBy = value; diff --git a/LibGit2Sharp/GitLink.cs b/LibGit2Sharp/GitLink.cs index 398ab321..f03b1d71 100644 --- a/LibGit2Sharp/GitLink.cs +++ b/LibGit2Sharp/GitLink.cs @@ -16,8 +16,7 @@ namespace LibGit2Sharp internal GitLink(Repository repo, ObjectId id) : base(repo, id) - { - } + { } private string DebuggerDisplay { diff --git a/LibGit2Sharp/GitObject.cs b/LibGit2Sharp/GitObject.cs index 9dbce189..fcad84da 100644 --- a/LibGit2Sharp/GitObject.cs +++ b/LibGit2Sharp/GitObject.cs @@ -15,12 +15,12 @@ namespace LibGit2Sharp { internal static IDictionary TypeToKindMap = new Dictionary - { - { typeof(Commit), ObjectType.Commit }, - { typeof(Tree), ObjectType.Tree }, - { typeof(Blob), ObjectType.Blob }, - { typeof(TagAnnotation), ObjectType.Tag }, - }; + { + { typeof(Commit), ObjectType.Commit }, + { typeof(Tree), ObjectType.Tree }, + { typeof(Blob), ObjectType.Blob }, + { typeof(TagAnnotation), ObjectType.Tag }, + }; private static readonly LambdaEqualityHelper equalityHelper = new LambdaEqualityHelper(x => x.Id); @@ -66,12 +66,16 @@ namespace LibGit2Sharp { case GitObjectType.Commit: return new Commit(repo, id); + case GitObjectType.Tree: return new Tree(repo, id, path); + case GitObjectType.Tag: return new TagAnnotation(repo, id); + case GitObjectType.Blob: return new Blob(repo, id); + default: throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unexpected type '{0}' for object '{1}'.", diff --git a/LibGit2Sharp/GlobalSettings.cs b/LibGit2Sharp/GlobalSettings.cs index d312b3a4..c9ca5109 100644 --- a/LibGit2Sharp/GlobalSettings.cs +++ b/LibGit2Sharp/GlobalSettings.cs @@ -61,10 +61,9 @@ namespace LibGit2Sharp try { - Proxy.git_transport_register( - registration.Scheme, - registration.FunctionPointer, - registration.RegistrationPointer); + Proxy.git_transport_register(registration.Scheme, + registration.FunctionPointer, + registration.RegistrationPointer); } catch (Exception) { diff --git a/LibGit2Sharp/HistoryDivergence.cs b/LibGit2Sharp/HistoryDivergence.cs index 7c54b6be..262c09c1 100644 --- a/LibGit2Sharp/HistoryDivergence.cs +++ b/LibGit2Sharp/HistoryDivergence.cs @@ -64,10 +64,7 @@ namespace LibGit2Sharp /// public virtual Commit CommonAncestor { - get - { - return commonAncestor.Value; - } + get { return commonAncestor.Value; } } } diff --git a/LibGit2Sharp/IRepository.cs b/LibGit2Sharp/IRepository.cs index 391cce1e..d57f54e2 100644 --- a/LibGit2Sharp/IRepository.cs +++ b/LibGit2Sharp/IRepository.cs @@ -52,7 +52,7 @@ namespace LibGit2Sharp /// /// Provides access to diffing functionalities to show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, or changes between two files on disk. /// - Diff Diff {get;} + Diff Diff { get; } /// /// Gets the database. diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs index 36dd60b7..f63c91d7 100644 --- a/LibGit2Sharp/Index.cs +++ b/LibGit2Sharp/Index.cs @@ -245,17 +245,17 @@ namespace LibGit2Sharp continue; case ChangeKind.Deleted: - /* Fall through */ case ChangeKind.Modified: - AddEntryToTheIndex( - treeEntryChanges.OldPath, - treeEntryChanges.OldOid, - treeEntryChanges.OldMode); - + AddEntryToTheIndex(treeEntryChanges.OldPath, + treeEntryChanges.OldOid, + treeEntryChanges.OldMode); continue; default: - throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "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)); } } @@ -267,10 +267,7 @@ namespace LibGit2Sharp /// public virtual ConflictCollection Conflicts { - get - { - return conflicts; - } + get { return conflicts; } } private void AddEntryToTheIndex(string path, ObjectId id, Mode mode) @@ -290,8 +287,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", Count); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", Count); } } diff --git a/LibGit2Sharp/IndexEntry.cs b/LibGit2Sharp/IndexEntry.cs index 7dc6b015..b8a39db6 100644 --- a/LibGit2Sharp/IndexEntry.cs +++ b/LibGit2Sharp/IndexEntry.cs @@ -52,13 +52,13 @@ namespace LibGit2Sharp FilePath path = LaxFilePathMarshaler.FromNative(entry.Path); return new IndexEntry - { - Path = path.Native, - Id = entry.Id, - StageLevel = Proxy.git_index_entry_stage(handle), - Mode = (Mode)entry.Mode, - AssumeUnchanged = (GitIndexEntry.GIT_IDXENTRY_VALID & entry.Flags) == GitIndexEntry.GIT_IDXENTRY_VALID - }; + { + Path = path.Native, + Id = entry.Id, + StageLevel = Proxy.git_index_entry_stage(handle), + Mode = (Mode)entry.Mode, + AssumeUnchanged = (GitIndexEntry.GIT_IDXENTRY_VALID & entry.Flags) == GitIndexEntry.GIT_IDXENTRY_VALID + }; } /// @@ -117,7 +117,10 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0} ({1}) => \"{2}\"", Path, StageLevel, Id.ToString(7)); + "{0} ({1}) => \"{2}\"", + Path, + StageLevel, + Id.ToString(7)); } } } diff --git a/LibGit2Sharp/IndexNameEntry.cs b/LibGit2Sharp/IndexNameEntry.cs index ef6fc50d..b8153c95 100644 --- a/LibGit2Sharp/IndexNameEntry.cs +++ b/LibGit2Sharp/IndexNameEntry.cs @@ -31,12 +31,15 @@ namespace LibGit2Sharp GitIndexNameEntry entry = handle.MarshalAsGitIndexNameEntry(); - string ancestor = entry.Ancestor != IntPtr.Zero ? - LaxFilePathMarshaler.FromNative(entry.Ancestor).Native : null; - string ours = entry.Ours != IntPtr.Zero ? - LaxFilePathMarshaler.FromNative(entry.Ours).Native : null; - string theirs = entry.Theirs != IntPtr.Zero ? - LaxFilePathMarshaler.FromNative(entry.Theirs).Native : null; + string ancestor = entry.Ancestor != IntPtr.Zero + ? LaxFilePathMarshaler.FromNative(entry.Ancestor).Native + : null; + string ours = entry.Ours != IntPtr.Zero + ? LaxFilePathMarshaler.FromNative(entry.Ours).Native + : null; + string theirs = entry.Theirs != IntPtr.Zero + ? LaxFilePathMarshaler.FromNative(entry.Theirs).Native + : null; return new IndexNameEntry { @@ -117,7 +120,10 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0} {1} {2}", Ancestor, Ours, Theirs); + "{0} {1} {2}", + Ancestor, + Ours, + Theirs); } } } diff --git a/LibGit2Sharp/IndexReucEntry.cs b/LibGit2Sharp/IndexReucEntry.cs index ffba71e0..788f14be 100644 --- a/LibGit2Sharp/IndexReucEntry.cs +++ b/LibGit2Sharp/IndexReucEntry.cs @@ -15,9 +15,9 @@ namespace LibGit2Sharp { private static readonly LambdaEqualityHelper equalityHelper = new LambdaEqualityHelper(x => x.Path, - x => x.AncestorId, x => x.AncestorMode, - x => x.OurId, x => x.OurMode, - x => x.TheirId, x => x.TheirMode); + x => x.AncestorId, x => x.AncestorMode, + x => x.OurId, x => x.OurMode, + x => x.TheirId, x => x.TheirMode); /// /// Needed for mocking purposes. @@ -145,7 +145,11 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0}: {1} {2} {3}", Path, AncestorId, OurId, TheirId); + "{0}: {1} {2} {3}", + Path, + AncestorId, + OurId, + TheirId); } } } diff --git a/LibGit2Sharp/InvalidSpecificationException.cs b/LibGit2Sharp/InvalidSpecificationException.cs index 7c82a437..0b71be89 100644 --- a/LibGit2Sharp/InvalidSpecificationException.cs +++ b/LibGit2Sharp/InvalidSpecificationException.cs @@ -17,8 +17,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public InvalidSpecificationException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -26,8 +25,7 @@ namespace LibGit2Sharp /// A message that describes the error. public InvalidSpecificationException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -36,8 +34,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public InvalidSpecificationException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -46,12 +43,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected InvalidSpecificationException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal InvalidSpecificationException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/LibGit2SharpException.cs b/LibGit2Sharp/LibGit2SharpException.cs index d5947b02..3621b8cc 100644 --- a/LibGit2Sharp/LibGit2SharpException.cs +++ b/LibGit2Sharp/LibGit2SharpException.cs @@ -15,8 +15,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public LibGit2SharpException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -24,8 +23,7 @@ namespace LibGit2Sharp /// A message that describes the error. public LibGit2SharpException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -34,8 +32,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public LibGit2SharpException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -55,14 +52,12 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected LibGit2SharpException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal LibGit2SharpException(string message, GitErrorCode code, GitErrorCategory category) : this(message) { Data.Add("libgit2.code", (int)code); Data.Add("libgit2.category", (int)category); - } } } diff --git a/LibGit2Sharp/LockedFileException.cs b/LibGit2Sharp/LockedFileException.cs index a086a7b0..67abe025 100644 --- a/LibGit2Sharp/LockedFileException.cs +++ b/LibGit2Sharp/LockedFileException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public LockedFileException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public LockedFileException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -33,8 +31,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public LockedFileException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -43,12 +40,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected LockedFileException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal LockedFileException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/LogConfiguration.cs b/LibGit2Sharp/LogConfiguration.cs index 67c974bd..dd63bf30 100644 --- a/LibGit2Sharp/LogConfiguration.cs +++ b/LibGit2Sharp/LogConfiguration.cs @@ -33,8 +33,7 @@ namespace LibGit2Sharp } private LogConfiguration() - { - } + { } internal LogLevel Level { get; private set; } internal LogHandler Handler { get; private set; } diff --git a/LibGit2Sharp/MergeConflictException.cs b/LibGit2Sharp/MergeConflictException.cs index 0d868919..c1eab05b 100644 --- a/LibGit2Sharp/MergeConflictException.cs +++ b/LibGit2Sharp/MergeConflictException.cs @@ -10,6 +10,5 @@ namespace LibGit2Sharp [Serializable] [Obsolete("This type will be removed in the next release. Please use CheckoutConflictException instead.")] public class MergeConflictException : CheckoutConflictException - { - } + { } } diff --git a/LibGit2Sharp/MergeFetchHeadNotFoundException.cs b/LibGit2Sharp/MergeFetchHeadNotFoundException.cs index 26c3844a..913b79ea 100644 --- a/LibGit2Sharp/MergeFetchHeadNotFoundException.cs +++ b/LibGit2Sharp/MergeFetchHeadNotFoundException.cs @@ -13,8 +13,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public MergeFetchHeadNotFoundException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -22,8 +21,7 @@ namespace LibGit2Sharp /// A message that describes the error. public MergeFetchHeadNotFoundException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -32,8 +30,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public MergeFetchHeadNotFoundException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -42,7 +39,6 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected MergeFetchHeadNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } } } diff --git a/LibGit2Sharp/MergeHead.cs b/LibGit2Sharp/MergeHead.cs index 2ad50817..b548b254 100644 --- a/LibGit2Sharp/MergeHead.cs +++ b/LibGit2Sharp/MergeHead.cs @@ -15,8 +15,7 @@ namespace LibGit2Sharp internal MergeHead(Repository repo, ObjectId targetId, int index) : base(repo, new DirectReference(string.Format(CultureInfo.InvariantCulture, "MERGE_HEAD[{0}]", index), repo, targetId), r => r.CanonicalName) - { - } + { } /// /// Gets the that this merge head points to. diff --git a/LibGit2Sharp/MergeOptions.cs b/LibGit2Sharp/MergeOptions.cs index 535d9a91..c36e6ddc 100644 --- a/LibGit2Sharp/MergeOptions.cs +++ b/LibGit2Sharp/MergeOptions.cs @@ -17,8 +17,7 @@ namespace LibGit2Sharp /// /// public MergeOptions() - { - } + { } /// /// The type of merge to perform. diff --git a/LibGit2Sharp/MergeTreeOptions.cs b/LibGit2Sharp/MergeTreeOptions.cs index 910ec95f..a9eea97e 100644 --- a/LibGit2Sharp/MergeTreeOptions.cs +++ b/LibGit2Sharp/MergeTreeOptions.cs @@ -13,7 +13,6 @@ /// /// public MergeTreeOptions() - { - } + { } } } diff --git a/LibGit2Sharp/MergeTreeResult.cs b/LibGit2Sharp/MergeTreeResult.cs index 2f54d956..c871c627 100644 --- a/LibGit2Sharp/MergeTreeResult.cs +++ b/LibGit2Sharp/MergeTreeResult.cs @@ -29,31 +29,19 @@ namespace LibGit2Sharp /// /// The status of the merge. /// - public virtual MergeTreeStatus Status - { - get; - private set; - } + public virtual MergeTreeStatus Status { get; private set; } /// /// The resulting tree of the merge. /// This will return null if the merge has been unsuccessful due to conflicts. /// - public virtual Tree Tree - { - get; - private set; - } + public virtual Tree Tree { get; private set; } /// /// The resulting conflicts from the merge. /// This will return null if the merge was successful and there were no conflicts. /// - public virtual IEnumerable Conflicts - { - get; - private set; - } + public virtual IEnumerable Conflicts { get; private set; } } /// diff --git a/LibGit2Sharp/NameConflictException.cs b/LibGit2Sharp/NameConflictException.cs index 16d1bf09..ddd56156 100644 --- a/LibGit2Sharp/NameConflictException.cs +++ b/LibGit2Sharp/NameConflictException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public NameConflictException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public NameConflictException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -33,8 +31,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public NameConflictException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -43,12 +40,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected NameConflictException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal NameConflictException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/Network.cs b/LibGit2Sharp/Network.cs index 189cd778..55f773f4 100644 --- a/LibGit2Sharp/Network.cs +++ b/LibGit2Sharp/Network.cs @@ -152,11 +152,12 @@ namespace LibGit2Sharp return remoteHandle; } - static void DoFetch(RepositorySafeHandle repoHandle, - Remote remote, - FetchOptions options, - string logMessage, - IEnumerable refspecs) + static void DoFetch( + RepositorySafeHandle repoHandle, + Remote remote, + FetchOptions options, + string logMessage, + IEnumerable refspecs) { using (RemoteSafeHandle remoteHandle = BuildRemoteSafeHandle(repoHandle, remote)) { @@ -164,11 +165,12 @@ namespace LibGit2Sharp } } - static void DoFetch(RepositorySafeHandle repoHandle, - string url, - FetchOptions options, - string logMessage, - IEnumerable refspecs) + static void DoFetch( + RepositorySafeHandle repoHandle, + string url, + FetchOptions options, + string logMessage, + IEnumerable refspecs) { using (RemoteSafeHandle remoteHandle = BuildRemoteSafeHandle(repoHandle, url)) { @@ -301,9 +303,7 @@ namespace LibGit2Sharp /// /// The url to fetch from /// The list of resfpecs to use - public virtual void Fetch( - string url, - IEnumerable refspecs) + public virtual void Fetch(string url, IEnumerable refspecs) { Fetch(url, refspecs, null, null); } @@ -314,10 +314,7 @@ namespace LibGit2Sharp /// The url to fetch from /// The list of resfpecs to use /// controlling fetch behavior - public virtual void Fetch( - string url, - IEnumerable refspecs, - FetchOptions options) + public virtual void Fetch(string url, IEnumerable refspecs, FetchOptions options) { Fetch(url, refspecs, options, null); } @@ -328,10 +325,7 @@ namespace LibGit2Sharp /// The url to fetch from /// The list of resfpecs to use /// Message to use when updating the reflog. - public virtual void Fetch( - string url, - IEnumerable refspecs, - string logMessage) + public virtual void Fetch(string url, IEnumerable refspecs, string logMessage) { Fetch(url, refspecs, null, logMessage); } @@ -435,8 +429,11 @@ namespace LibGit2Sharp Ensure.ArgumentNotNull(objectish, "objectish"); Ensure.ArgumentNotNullOrEmptyString(destinationSpec, "destinationSpec"); - Push(remote, string.Format(CultureInfo.InvariantCulture, - "{0}:{1}", objectish, destinationSpec)); + Push(remote, + string.Format(CultureInfo.InvariantCulture, + "{0}:{1}", + objectish, + destinationSpec)); } /// @@ -455,8 +452,12 @@ namespace LibGit2Sharp Ensure.ArgumentNotNull(objectish, "objectish"); Ensure.ArgumentNotNullOrEmptyString(destinationSpec, "destinationSpec"); - Push(remote, string.Format(CultureInfo.InvariantCulture, - "{0}:{1}", objectish, destinationSpec), pushOptions); + Push(remote, + string.Format(CultureInfo.InvariantCulture, + "{0}:{1}", + objectish, + destinationSpec), + pushOptions); } /// @@ -464,9 +465,7 @@ namespace LibGit2Sharp /// /// The to push to. /// The pushRefSpec to push. - public virtual void Push( - Remote remote, - string pushRefSpec) + public virtual void Push(Remote remote, string pushRefSpec) { Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, "pushRefSpec"); @@ -493,9 +492,7 @@ namespace LibGit2Sharp /// /// The to push to. /// The pushRefSpecs to push. - public virtual void Push( - Remote remote, - IEnumerable pushRefSpecs) + public virtual void Push(Remote remote, IEnumerable pushRefSpecs) { Push(remote, pushRefSpecs, null); } @@ -506,10 +503,7 @@ namespace LibGit2Sharp /// The to push to. /// The pushRefSpecs to push. /// controlling push behavior - public virtual void Push( - Remote remote, - IEnumerable pushRefSpecs, - PushOptions pushOptions) + public virtual void Push(Remote remote, IEnumerable pushRefSpecs, PushOptions pushOptions) { Ensure.ArgumentNotNull(remote, "remote"); Ensure.ArgumentNotNull(pushRefSpecs, "pushRefSpecs"); @@ -531,12 +525,13 @@ namespace LibGit2Sharp var callbacks = new RemoteCallbacks(pushOptions); GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); - Proxy.git_remote_push(remoteHandle, pushRefSpecs, - new GitPushOptions() - { - PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism, - RemoteCallbacks = gitCallbacks, - }); + Proxy.git_remote_push(remoteHandle, + pushRefSpecs, + new GitPushOptions() + { + PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism, + RemoteCallbacks = gitCallbacks, + }); } } @@ -575,9 +570,10 @@ namespace LibGit2Sharp { int i = 0; - return Proxy.git_repository_fetchhead_foreach( - repository.Handle, - (name, url, oid, isMerge) => new FetchHead(repository, name, url, oid, isMerge, i++)); + Func resultSelector = + (name, url, oid, isMerge) => new FetchHead(repository, name, url, oid, isMerge, i++); + + return Proxy.git_repository_fetchhead_foreach(repository.Handle, resultSelector); } } } diff --git a/LibGit2Sharp/NonFastForwardException.cs b/LibGit2Sharp/NonFastForwardException.cs index 2cf4ccd9..7431058c 100644 --- a/LibGit2Sharp/NonFastForwardException.cs +++ b/LibGit2Sharp/NonFastForwardException.cs @@ -15,8 +15,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public NonFastForwardException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -24,8 +23,7 @@ namespace LibGit2Sharp /// A message that describes the error. public NonFastForwardException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -34,8 +32,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public NonFastForwardException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -44,12 +41,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected NonFastForwardException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal NonFastForwardException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/NotFoundException.cs b/LibGit2Sharp/NotFoundException.cs index c2a32ed0..4b8c1003 100644 --- a/LibGit2Sharp/NotFoundException.cs +++ b/LibGit2Sharp/NotFoundException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public NotFoundException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public NotFoundException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -33,8 +31,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public NotFoundException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -43,12 +40,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected NotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal NotFoundException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/Note.cs b/LibGit2Sharp/Note.cs index 89a4eb65..0feebb9d 100644 --- a/LibGit2Sharp/Note.cs +++ b/LibGit2Sharp/Note.cs @@ -12,6 +12,9 @@ namespace LibGit2Sharp [DebuggerDisplay("{DebuggerDisplay,nq}")] public class Note : IEquatable { + private static readonly LambdaEqualityHelper equalityHelper = + new LambdaEqualityHelper(x => x.BlobId, x => x.TargetObjectId, x => x.Namespace); + /// /// Needed for mocking purposes. /// @@ -55,9 +58,6 @@ namespace LibGit2Sharp return new Note(oid, message, targetObjectId, @namespace); } - private static readonly LambdaEqualityHelper equalityHelper = - new LambdaEqualityHelper(x => x.BlobId, x => x.TargetObjectId, x => x.Namespace); - /// /// Determines whether the specified is equal to the current . /// @@ -114,8 +114,10 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "Target \"{0}\", Namespace \"{1}\": {2}", - TargetObjectId.ToString(7), Namespace, Message); + "Target \"{0}\", Namespace \"{1}\": {2}", + TargetObjectId.ToString(7), + Namespace, + Message); } } } diff --git a/LibGit2Sharp/NoteCollection.cs b/LibGit2Sharp/NoteCollection.cs index 8ea0a0fe..7d8c756d 100644 --- a/LibGit2Sharp/NoteCollection.cs +++ b/LibGit2Sharp/NoteCollection.cs @@ -65,10 +65,7 @@ namespace LibGit2Sharp /// public virtual IEnumerable Namespaces { - get - { - return NamespaceRefs.Select(UnCanonicalizeName); - } + get { return NamespaceRefs.Select(UnCanonicalizeName); } } internal IEnumerable NamespaceRefs @@ -108,8 +105,9 @@ namespace LibGit2Sharp string canonicalNamespace = NormalizeToCanonicalName(@namespace); - return Proxy.git_note_foreach(repo.Handle, canonicalNamespace, - (blobId,annotatedObjId) => this[canonicalNamespace, annotatedObjId]); + return Proxy.git_note_foreach(repo.Handle, + canonicalNamespace, + (blobId, annotatedObjId) => this[canonicalNamespace, annotatedObjId]); } } @@ -242,8 +240,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } } diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs index 4f9cfe7d..d855e2c6 100644 --- a/LibGit2Sharp/ObjectDatabase.cs +++ b/LibGit2Sharp/ObjectDatabase.cs @@ -42,7 +42,7 @@ namespace LibGit2Sharp public virtual IEnumerator GetEnumerator() { ICollection oids = Proxy.git_odb_foreach(handle, - ptr => ptr.MarshalAs()); + ptr => ptr.MarshalAs()); return oids .Select(gitOid => repo.Lookup(new ObjectId(gitOid))) @@ -99,14 +99,14 @@ namespace LibGit2Sharp if (repo.Info.IsBare && !Path.IsPathRooted(path)) { - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, - "Cannot create a blob in a bare repository from a relative path ('{0}').", path)); + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, + "Cannot create a blob in a bare repository from a relative path ('{0}').", + path)); } ObjectId id = Path.IsPathRooted(path) - ? Proxy.git_blob_create_fromdisk(repo.Handle, path) - : Proxy.git_blob_create_fromfile(repo.Handle, path); + ? Proxy.git_blob_create_fromdisk(repo.Handle, path) + : Proxy.git_blob_create_fromfile(repo.Handle, path); return repo.Lookup(id); } @@ -152,7 +152,9 @@ namespace LibGit2Sharp if (totalRemainingBytesToRead < max_length) { - bytesToRead = totalRemainingBytesToRead > int.MaxValue ? int.MaxValue : (int)totalRemainingBytesToRead; + bytesToRead = totalRemainingBytesToRead > int.MaxValue + ? int.MaxValue + : (int)totalRemainingBytesToRead; } } @@ -163,8 +165,7 @@ namespace LibGit2Sharp int numberOfReadBytes = stream.Read(local, 0, bytesToRead); - if (numberOfBytesToConsume.HasValue - && numberOfReadBytes == 0) + if (numberOfBytesToConsume.HasValue && numberOfReadBytes == 0) { return (int)GitErrorCode.User; } @@ -251,7 +252,7 @@ namespace LibGit2Sharp using (var odbStream = Proxy.git_odb_open_wstream(handle, numberOfBytesToConsume, GitObjectType.Blob)) { - var buffer = new byte[4*1024]; + var buffer = new byte[4 * 1024]; long totalRead = 0; while (totalRead < numberOfBytesToConsume) @@ -488,8 +489,10 @@ namespace LibGit2Sharp if (minLength <= 0 || minLength > ObjectId.HexSize) { - throw new ArgumentOutOfRangeException("minLength", minLength, - string.Format("Expected value should be greater than zero and less than or equal to {0}.", ObjectId.HexSize)); + throw new ArgumentOutOfRangeException("minLength", + minLength, + string.Format("Expected value should be greater than zero and less than or equal to {0}.", + ObjectId.HexSize)); } string shortSha = Proxy.git_object_short_id(repo.Handle, gitObject.Id); @@ -571,9 +574,11 @@ namespace LibGit2Sharp case MergeBaseFindingStrategy.Standard: id = Proxy.git_merge_base_many(repo.Handle, ids.ToArray()); break; + case MergeBaseFindingStrategy.Octopus: id = Proxy.git_merge_base_octopus(repo.Handle, ids.ToArray()); break; + default: throw new ArgumentException("", "strategy"); } @@ -602,8 +607,8 @@ namespace LibGit2Sharp { Version = 1, MergeFileFavorFlags = options.MergeFileFavor, - MergeTreeFlags = options.FindRenames ? GitMergeTreeFlags.GIT_MERGE_TREE_FIND_RENAMES : - GitMergeTreeFlags.GIT_MERGE_TREE_NORMAL, + MergeTreeFlags = options.FindRenames ? GitMergeTreeFlags.GIT_MERGE_TREE_FIND_RENAMES + : GitMergeTreeFlags.GIT_MERGE_TREE_NORMAL, RenameThreshold = (uint)options.RenameThreshold, TargetLimit = (uint)options.TargetLimit, }; diff --git a/LibGit2Sharp/ObjectId.cs b/LibGit2Sharp/ObjectId.cs index 7b247e8a..f93817a4 100644 --- a/LibGit2Sharp/ObjectId.cs +++ b/LibGit2Sharp/ObjectId.cs @@ -297,9 +297,11 @@ namespace LibGit2Sharp return false; } - throw new ArgumentException( - string.Format(CultureInfo.InvariantCulture, "'{0}' is not a valid object identifier. Its length should be {1}.", objectId, HexSize), - "objectId"); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, + "'{0}' is not a valid object identifier. Its length should be {1}.", + objectId, + HexSize), + "objectId"); } return objectId.All(c => hexDigits.Contains(c.ToString(CultureInfo.InvariantCulture))); diff --git a/LibGit2Sharp/OdbBackend.cs b/LibGit2Sharp/OdbBackend.cs index 8ecd3f73..58b5f60b 100644 --- a/LibGit2Sharp/OdbBackend.cs +++ b/LibGit2Sharp/OdbBackend.cs @@ -33,10 +33,7 @@ namespace LibGit2Sharp /// /// In your subclass, override this member to provide the list of actions your backend supports. /// - protected abstract OdbBackendOperations SupportedOperations - { - get; - } + protected abstract OdbBackendOperations SupportedOperations { get; } /// /// Call this method from your implementations of Read and ReadPrefix to allocate a buffer in @@ -64,8 +61,7 @@ namespace LibGit2Sharp /// A Stream for you to write to and then return. Do not dispose this object before returning it. protected unsafe UnmanagedMemoryStream Allocate(long size) { - if (size < 0 || - (UIntPtr.Size == sizeof(int) && size > int.MaxValue)) + if (size < 0 || (UIntPtr.Size == sizeof(int) && size > int.MaxValue)) { throw new ArgumentOutOfRangeException("size"); } @@ -330,7 +326,7 @@ namespace LibGit2Sharp try { - var shortSha = ObjectId.ToString(short_oid.Id, (int) len); + var shortSha = ObjectId.ToString(short_oid.Id, (int)len); ObjectId oid; ObjectType objectType; @@ -545,7 +541,7 @@ namespace LibGit2Sharp found_oid.Id = ObjectId.Zero.RawId; int result = odbBackend.ExistsPrefix(shortSha, out found); - if (result == (int) GitErrorCode.Ok) + if (result == (int)GitErrorCode.Ok) { found_oid.Id = found.RawId; } @@ -622,7 +618,7 @@ namespace LibGit2Sharp { var oid = id.RawId; - fixed(void* ptr = &oid[0]) + fixed (void* ptr = &oid[0]) { return cb(new IntPtr(ptr), data); } @@ -639,11 +635,10 @@ namespace LibGit2Sharp { if (len.ToUInt64() > long.MaxValue) { - throw new InvalidOperationException( - string.Format( - CultureInfo.InvariantCulture, - "Provided length ({0}) exceeds long.MaxValue ({1}).", - len.ToUInt64(), long.MaxValue)); + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, + "Provided length ({0}) exceeds long.MaxValue ({1}).", + len.ToUInt64(), + long.MaxValue)); } return (long)len.ToUInt64(); diff --git a/LibGit2Sharp/OdbBackendStream.cs b/LibGit2Sharp/OdbBackendStream.cs index 6397b7bb..2889ac20 100644 --- a/LibGit2Sharp/OdbBackendStream.cs +++ b/LibGit2Sharp/OdbBackendStream.cs @@ -45,48 +45,34 @@ namespace LibGit2Sharp /// /// If true, then it is legal to call the Read method. /// - public abstract bool CanRead - { - get; - } + public abstract bool CanRead { get; } /// /// If true, then it is legal to call the Write and FinalizeWrite methods. /// - public abstract bool CanWrite - { - get; - } + public abstract bool CanWrite { get; } /// /// Requests that the stream write the next length bytes of the stream to the provided Stream object. /// - public abstract int Read( - Stream dataStream, - long length); + public abstract int Read(Stream dataStream, long length); /// /// Requests that the stream write the first length bytes of the provided Stream object to the stream. /// - public abstract int Write( - Stream dataStream, - long length); + public abstract int Write(Stream dataStream, long length); /// /// After all bytes have been written to the stream, the object ID is provided to FinalizeWrite. /// - public abstract int FinalizeWrite( - ObjectId id); + public abstract int FinalizeWrite(ObjectId id); /// /// The backend object this stream was created by. /// public virtual OdbBackend Backend { - get - { - return this.backend; - } + get { return this.backend; } } private readonly OdbBackend backend; @@ -138,10 +124,7 @@ namespace LibGit2Sharp public static readonly GitOdbBackendStream.finalize_write_callback FinalizeWriteCallback = FinalizeWrite; public static readonly GitOdbBackendStream.free_callback FreeCallback = Free; - private unsafe static int Read( - IntPtr stream, - IntPtr buffer, - UIntPtr len) + private unsafe static int Read(IntPtr stream, IntPtr buffer, UIntPtr len) { OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream; @@ -165,10 +148,7 @@ namespace LibGit2Sharp return (int)GitErrorCode.Error; } - private static unsafe int Write( - IntPtr stream, - IntPtr buffer, - UIntPtr len) + private static unsafe int Write(IntPtr stream, IntPtr buffer, UIntPtr len) { OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream; @@ -192,9 +172,7 @@ namespace LibGit2Sharp return (int)GitErrorCode.Error; } - private static int FinalizeWrite( - IntPtr stream, - ref GitOid oid) + private static int FinalizeWrite(IntPtr stream, ref GitOid oid) { OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream; @@ -213,8 +191,7 @@ namespace LibGit2Sharp return (int)GitErrorCode.Error; } - private static void Free( - IntPtr stream) + private static void Free(IntPtr stream) { OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream; diff --git a/LibGit2Sharp/Patch.cs b/LibGit2Sharp/Patch.cs index 4bbb884b..c437f4d3 100644 --- a/LibGit2Sharp/Patch.cs +++ b/LibGit2Sharp/Patch.cs @@ -58,7 +58,9 @@ namespace LibGit2Sharp // Deleted files mean no "new file" path - var pathPtr = delta.NewFile.Path != IntPtr.Zero ? delta.NewFile.Path : delta.OldFile.Path; + var pathPtr = delta.NewFile.Path != IntPtr.Zero + ? delta.NewFile.Path + : delta.OldFile.Path; var filePath = LaxFilePathMarshaler.FromNative(pathPtr); PatchEntryChanges currentChange = this[filePath]; @@ -164,7 +166,7 @@ namespace LibGit2Sharp /// /// . /// The patch content as string. - public static implicit operator string(Patch patch) + public static implicit operator string (Patch patch) { return patch.fullPatchBuilder.ToString(); } @@ -174,7 +176,9 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "+{0} -{1}", linesAdded, linesDeleted); + "+{0} -{1}", + linesAdded, + linesDeleted); } } } diff --git a/LibGit2Sharp/PatchStats.cs b/LibGit2Sharp/PatchStats.cs index f22eecb1..da92ac07 100644 --- a/LibGit2Sharp/PatchStats.cs +++ b/LibGit2Sharp/PatchStats.cs @@ -75,7 +75,7 @@ namespace LibGit2Sharp /// public virtual ContentChangeStats this[string path] { - get { return this[(FilePath) path]; } + get { return this[(FilePath)path]; } } private ContentChangeStats this[FilePath path] @@ -111,8 +111,10 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, "+{0} -{1}", - TotalLinesAdded, TotalLinesDeleted); + return string.Format(CultureInfo.InvariantCulture, + "+{0} -{1}", + TotalLinesAdded, + TotalLinesDeleted); } } } diff --git a/LibGit2Sharp/PeelException.cs b/LibGit2Sharp/PeelException.cs index e7fbfe79..629b6733 100644 --- a/LibGit2Sharp/PeelException.cs +++ b/LibGit2Sharp/PeelException.cs @@ -15,8 +15,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public PeelException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -24,8 +23,7 @@ namespace LibGit2Sharp /// A message that describes the error. public PeelException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -34,8 +32,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public PeelException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -44,12 +41,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected PeelException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal PeelException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/PushResult.cs b/LibGit2Sharp/PushResult.cs index bf85e3ab..713f13a5 100644 --- a/LibGit2Sharp/PushResult.cs +++ b/LibGit2Sharp/PushResult.cs @@ -18,10 +18,7 @@ namespace LibGit2Sharp /// public virtual IEnumerable FailedPushUpdates { - get - { - return failedPushUpdates; - } + get { return failedPushUpdates; } } /// @@ -30,10 +27,7 @@ namespace LibGit2Sharp /// public virtual bool HasErrors { - get - { - return failedPushUpdates.Count > 0; - } + get { return failedPushUpdates.Count > 0; } } internal PushResult(List failedPushUpdates) diff --git a/LibGit2Sharp/RecurseSubmodulesException.cs b/LibGit2Sharp/RecurseSubmodulesException.cs index 586261dd..c322f760 100644 --- a/LibGit2Sharp/RecurseSubmodulesException.cs +++ b/LibGit2Sharp/RecurseSubmodulesException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public RecurseSubmodulesException() - { - } + { } /// /// The path to the initial repository the operation was run on. diff --git a/LibGit2Sharp/RefSpec.cs b/LibGit2Sharp/RefSpec.cs index d0ac8b3b..9c811c5f 100644 --- a/LibGit2Sharp/RefSpec.cs +++ b/LibGit2Sharp/RefSpec.cs @@ -67,8 +67,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "{0}", Specification); + return string.Format(CultureInfo.InvariantCulture, "{0}", Specification); } } } diff --git a/LibGit2Sharp/RefSpecCollection.cs b/LibGit2Sharp/RefSpecCollection.cs index 1b7b5a13..163281a1 100644 --- a/LibGit2Sharp/RefSpecCollection.cs +++ b/LibGit2Sharp/RefSpecCollection.cs @@ -68,8 +68,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } } diff --git a/LibGit2Sharp/Reference.cs b/LibGit2Sharp/Reference.cs index d7542714..29742650 100644 --- a/LibGit2Sharp/Reference.cs +++ b/LibGit2Sharp/Reference.cs @@ -231,7 +231,9 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0} => \"{1}\"", CanonicalName, TargetIdentifier); + "{0} => \"{1}\"", + CanonicalName, + TargetIdentifier); } } diff --git a/LibGit2Sharp/ReferenceCollection.cs b/LibGit2Sharp/ReferenceCollection.cs index 241b3e11..4d2b9ece 100644 --- a/LibGit2Sharp/ReferenceCollection.cs +++ b/LibGit2Sharp/ReferenceCollection.cs @@ -245,8 +245,11 @@ namespace LibGit2Sharp Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(targetRef, "targetRef"); - using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_create(repo.Handle, name, targetRef.CanonicalName, - allowOverwrite, logMessage)) + using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_create(repo.Handle, + name, + targetRef.CanonicalName, + allowOverwrite, + logMessage)) { return (SymbolicReference)Reference.BuildFromPtr(handle, repo); } @@ -331,8 +334,13 @@ namespace LibGit2Sharp if (logMessage == null) { - logMessage = string.Format(CultureInfo.InvariantCulture, "{0}: renamed {1} to {2}", - reference.IsLocalBranch ? "branch" : "reference", reference.CanonicalName, newName); + logMessage = string.Format(CultureInfo.InvariantCulture, + "{0}: renamed {1} to {2}", + reference.IsLocalBranch + ? "branch" + : "reference", + reference.CanonicalName, + newName); } using (ReferenceSafeHandle referencePtr = RetrieveReferencePtr(reference.CanonicalName)) @@ -433,7 +441,9 @@ namespace LibGit2Sharp using (ReferenceSafeHandle referencePtr = RetrieveReferencePtr(name, false)) { - return referencePtr == null ? null : Reference.BuildFromPtr(referencePtr, repo); + return referencePtr == null + ? null + : Reference.BuildFromPtr(referencePtr, repo); } } @@ -633,7 +643,8 @@ namespace LibGit2Sharp else { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, - "'{0}' is not a valid target type.", typeof(T))); + "'{0}' is not a valid target type.", + typeof(T))); } return repo.Refs.Head; @@ -761,8 +772,7 @@ namespace LibGit2Sharp /// /// The set of s that are interesting. /// The list of that can reach at least one within . - public virtual IEnumerable ReachableFrom( - IEnumerable targets) + public virtual IEnumerable ReachableFrom(IEnumerable targets) { return ReachableFrom(this, targets); } @@ -771,8 +781,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } diff --git a/LibGit2Sharp/ReferenceWrapper.cs b/LibGit2Sharp/ReferenceWrapper.cs index e6fa0779..391ff3cc 100644 --- a/LibGit2Sharp/ReferenceWrapper.cs +++ b/LibGit2Sharp/ReferenceWrapper.cs @@ -165,8 +165,10 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0} => \"{1}\"", CanonicalName, - (TargetObject != null) ? TargetObject.Id.ToString(7) : "?"); + "{0} => \"{1}\"", CanonicalName, + (TargetObject != null) + ? TargetObject.Id.ToString(7) + : "?"); } } diff --git a/LibGit2Sharp/ReflogCollection.cs b/LibGit2Sharp/ReflogCollection.cs index d2bbb891..0b2e6e11 100644 --- a/LibGit2Sharp/ReflogCollection.cs +++ b/LibGit2Sharp/ReflogCollection.cs @@ -87,8 +87,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } } diff --git a/LibGit2Sharp/Remote.cs b/LibGit2Sharp/Remote.cs index efa716a8..13720819 100644 --- a/LibGit2Sharp/Remote.cs +++ b/LibGit2Sharp/Remote.cs @@ -59,15 +59,10 @@ namespace LibGit2Sharp /// Gets the distinct push url for this remote repository, if set. /// Defaults to the fetch url () if not set. /// - public virtual string PushUrl { - get - { - return pushUrl ?? Url; - } - private set - { - pushUrl = value; - } + public virtual string PushUrl + { + get { return pushUrl ?? Url; } + private set { pushUrl = value; } } /// @@ -202,8 +197,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "{0} => {1}", Name, Url); + return string.Format(CultureInfo.InvariantCulture, "{0} => {1}", Name, Url); } } diff --git a/LibGit2Sharp/RemoteCallbacks.cs b/LibGit2Sharp/RemoteCallbacks.cs index 8d8a06a9..6dacf492 100644 --- a/LibGit2Sharp/RemoteCallbacks.cs +++ b/LibGit2Sharp/RemoteCallbacks.cs @@ -253,7 +253,12 @@ namespace LibGit2Sharp return Proxy.ConvertResultToCancelFlag(shouldContinue); } - private int GitCredentialHandler(out IntPtr ptr, IntPtr cUrl, IntPtr usernameFromUrl, GitCredentialType credTypes, IntPtr payload) + private int GitCredentialHandler( + out IntPtr ptr, + IntPtr cUrl, + IntPtr usernameFromUrl, + GitCredentialType credTypes, + IntPtr payload) { string url = LaxUtf8Marshaler.FromNative(cUrl); string username = LaxUtf8Marshaler.FromNative(usernameFromUrl); diff --git a/LibGit2Sharp/RemoteCollection.cs b/LibGit2Sharp/RemoteCollection.cs index a85cb6ad..6ab1a3fa 100644 --- a/LibGit2Sharp/RemoteCollection.cs +++ b/LibGit2Sharp/RemoteCollection.cs @@ -170,8 +170,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } } diff --git a/LibGit2Sharp/RemoteUpdater.cs b/LibGit2Sharp/RemoteUpdater.cs index 07ef39db..cb0e08b3 100644 --- a/LibGit2Sharp/RemoteUpdater.cs +++ b/LibGit2Sharp/RemoteUpdater.cs @@ -75,10 +75,7 @@ namespace LibGit2Sharp /// public virtual TagFetchMode TagFetchMode { - set - { - Proxy.git_remote_set_autotag(repo.Handle, remote.Name, value); - } + set { Proxy.git_remote_set_autotag(repo.Handle, remote.Name, value); } } /// @@ -86,10 +83,7 @@ namespace LibGit2Sharp /// public virtual string Url { - set - { - Proxy.git_remote_set_url(repo.Handle, remote.Name, value); - } + set { Proxy.git_remote_set_url(repo.Handle, remote.Name, value); } } /// @@ -97,10 +91,7 @@ namespace LibGit2Sharp /// public virtual string PushUrl { - set - { - Proxy.git_remote_set_pushurl(repo.Handle, remote.Name, value); - } + set { Proxy.git_remote_set_pushurl(repo.Handle, remote.Name, value); } } /// diff --git a/LibGit2Sharp/RemoveFromIndexException.cs b/LibGit2Sharp/RemoveFromIndexException.cs index 9f086312..a1cea4bb 100644 --- a/LibGit2Sharp/RemoveFromIndexException.cs +++ b/LibGit2Sharp/RemoveFromIndexException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public RemoveFromIndexException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public RemoveFromIndexException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -44,8 +42,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public RemoveFromIndexException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -54,7 +51,6 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected RemoveFromIndexException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } } } diff --git a/LibGit2Sharp/RenameDetails.cs b/LibGit2Sharp/RenameDetails.cs index 199b7269..b866aac6 100644 --- a/LibGit2Sharp/RenameDetails.cs +++ b/LibGit2Sharp/RenameDetails.cs @@ -110,9 +110,11 @@ namespace LibGit2Sharp { get { - return string.Format( - CultureInfo.InvariantCulture, - "{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 d01c3677..0c9b004c 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -82,8 +82,7 @@ namespace LibGit2Sharp if (isBare && (isWorkDirNull ^ isIndexNull)) { - throw new ArgumentException( - "When overriding the opening of a bare repository, both RepositoryOptions.WorkingDirectoryPath an RepositoryOptions.IndexPath have to be provided."); + throw new ArgumentException("When overriding the opening of a bare repository, both RepositoryOptions.WorkingDirectoryPath an RepositoryOptions.IndexPath have to be provided."); } if (!isWorkDirNull) @@ -122,11 +121,11 @@ namespace LibGit2Sharp tags = new TagCollection(this); stashes = new StashCollection(this); info = new Lazy(() => new RepositoryInformation(this, isBare)); - config = - new Lazy( - () => - RegisterForCleanup(new Configuration(this, null, configurationGlobalFilePath, configurationXDGFilePath, - configurationSystemFilePath))); + config = new Lazy(() => RegisterForCleanup(new Configuration(this, + null, + configurationGlobalFilePath, + configurationXDGFilePath, + configurationSystemFilePath))); odb = new Lazy(() => new ObjectDatabase(this)); diff = new Diff(this); notes = new NoteCollection(this); @@ -255,10 +254,7 @@ namespace LibGit2Sharp /// public Ignore Ignore { - get - { - return ignore; - } + get { return ignore; } } /// @@ -266,10 +262,7 @@ namespace LibGit2Sharp /// public Network Network { - get - { - return network.Value; - } + get { return network.Value; } } /// @@ -277,10 +270,7 @@ namespace LibGit2Sharp /// public ObjectDatabase ObjectDatabase { - get - { - return odb.Value; - } + get { return odb.Value; } } /// @@ -530,8 +520,7 @@ namespace LibGit2Sharp if (lookUpOptions.HasFlag(LookUpOptions.DereferenceResultToCommit)) { - return obj.DereferenceToCommit( - lookUpOptions.HasFlag(LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit)); + return obj.DereferenceToCommit(lookUpOptions.HasFlag(LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit)); } return obj; @@ -539,10 +528,11 @@ namespace LibGit2Sharp internal Commit LookupCommit(string committish) { - return (Commit)Lookup(committish, GitObjectType.Any, - LookUpOptions.ThrowWhenNoGitObjectHasBeenFound | - LookUpOptions.DereferenceResultToCommit | - LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit); + return (Commit)Lookup(committish, + GitObjectType.Any, + LookUpOptions.ThrowWhenNoGitObjectHasBeenFound | + LookUpOptions.DereferenceResultToCommit | + LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit); } /// @@ -657,7 +647,7 @@ namespace LibGit2Sharp bool continueOperation = OnRepositoryOperationStarting(options.RepositoryOperationStarting, context); - if(!continueOperation) + if (!continueOperation) { throw new UserCancelledException("Clone cancelled by the user."); } @@ -704,10 +694,9 @@ namespace LibGit2Sharp } catch (Exception ex) { - throw new RecurseSubmodulesException( - "The top level repository was cloned, but there was an error cloning its submodules.", - ex, - clonedRepoPath); + throw new RecurseSubmodulesException("The top level repository was cloned, but there was an error cloning its submodules.", + ex, + clonedRepoPath); } return clonedRepoPath; @@ -790,8 +779,9 @@ namespace LibGit2Sharp /// The callback to notify change. /// Context of the repository this operation affects. /// true to continue the operation, false to cancel. - private static bool OnRepositoryOperationStarting(RepositoryOperationStarting repositoryChangedCallback, - RepositoryOperationContext context) + private static bool OnRepositoryOperationStarting( + RepositoryOperationStarting repositoryChangedCallback, + RepositoryOperationContext context) { bool continueOperation = true; if (repositoryChangedCallback != null) @@ -802,8 +792,9 @@ namespace LibGit2Sharp return continueOperation; } - private static void OnRepositoryOperationCompleted(RepositoryOperationCompleted repositoryChangedCallback, - RepositoryOperationContext context) + private static void OnRepositoryOperationCompleted( + RepositoryOperationCompleted repositoryChangedCallback, + RepositoryOperationContext context) { if (repositoryChangedCallback != null) { @@ -858,8 +849,10 @@ namespace LibGit2Sharp } } - obj = GitObject.BuildFrom(this, Proxy.git_object_id(objH), Proxy.git_object_type(objH), - PathFromRevparseSpec(committishOrBranchSpec)); + obj = GitObject.BuildFrom(this, + Proxy.git_object_id(objH), + Proxy.git_object_type(objH), + PathFromRevparseSpec(committishOrBranchSpec)); } finally { @@ -889,7 +882,9 @@ namespace LibGit2Sharp // Make sure this is not an unborn branch. if (branch.Tip == null) { - throw new UnbornBranchException(CultureInfo.InvariantCulture, "The tip of branch '{0}' is null. There's nothing to checkout.", branch.FriendlyName); + throw new UnbornBranchException(CultureInfo.InvariantCulture, + "The tip of branch '{0}' is null. There's nothing to checkout.", + branch.FriendlyName); } if (!branch.IsRemote && !(branch is DetachedHead) && @@ -954,7 +949,7 @@ namespace LibGit2Sharp IConvertableToGitCheckoutOpts opts) { - using(GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(opts, ToFilePaths(paths))) + using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(opts, ToFilePaths(paths))) { var options = checkoutOptionsWrapper.Options; Proxy.git_checkout_tree(Handle, tree.Id, ref options); @@ -1117,7 +1112,7 @@ namespace LibGit2Sharp return; } - var symRef = (SymbolicReference) reference; + var symRef = (SymbolicReference)reference; reference = symRef.Target; @@ -1476,7 +1471,7 @@ namespace LibGit2Sharp FastForwardStrategy fastForwardStrategy = (options.FastForwardStrategy != FastForwardStrategy.Default) ? options.FastForwardStrategy : FastForwardStrategyFromMergePreference(mergePreference); - switch(fastForwardStrategy) + switch (fastForwardStrategy) { case FastForwardStrategy.Default: if (mergeAnalysis.HasFlag(GitMergeAnalysis.GIT_MERGE_ANALYSIS_FASTFORWARD)) @@ -1542,16 +1537,15 @@ namespace LibGit2Sharp private MergeResult NormalMerge(GitAnnotatedCommitHandle[] annotatedCommits, Signature merger, MergeOptions options) { MergeResult mergeResult; - var mergeOptions = new GitMergeOpts - { - Version = 1, - MergeFileFavorFlags = options.MergeFileFavor, - MergeTreeFlags = options.FindRenames ? GitMergeTreeFlags.GIT_MERGE_TREE_FIND_RENAMES : - GitMergeTreeFlags.GIT_MERGE_TREE_NORMAL, - RenameThreshold = (uint) options.RenameThreshold, - TargetLimit = (uint) options.TargetLimit, - }; + { + Version = 1, + MergeFileFavorFlags = options.MergeFileFavor, + MergeTreeFlags = options.FindRenames ? GitMergeTreeFlags.GIT_MERGE_TREE_FIND_RENAMES + : GitMergeTreeFlags.GIT_MERGE_TREE_NORMAL, + RenameThreshold = (uint)options.RenameThreshold, + TargetLimit = (uint)options.TargetLimit, + }; using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options)) { @@ -1588,7 +1582,7 @@ namespace LibGit2Sharp private MergeResult FastForwardMerge(GitAnnotatedCommitHandle annotatedCommit, MergeOptions options) { ObjectId id = Proxy.git_annotated_commit_id(annotatedCommit); - Commit fastForwardCommit = (Commit) Lookup(id, ObjectType.Commit); + Commit fastForwardCommit = (Commit)Lookup(id, ObjectType.Commit); Ensure.GitObjectIsNotNull(fastForwardCommit, id.Sha); CheckoutTree(fastForwardCommit.Tree, null, new FastForwardCheckoutOptionsAdapter(options)); @@ -2092,7 +2086,7 @@ namespace LibGit2Sharp case ChangeKind.Unmodified: if (removeFromWorkingDirectory && ( status.HasFlag(FileStatus.ModifiedInIndex) || - status.HasFlag(FileStatus.NewInIndex) )) + status.HasFlag(FileStatus.NewInIndex))) { throw new RemoveFromIndexException(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs index 385c5a9a..9c644667 100644 --- a/LibGit2Sharp/RepositoryExtensions.cs +++ b/LibGit2Sharp/RepositoryExtensions.cs @@ -357,7 +357,8 @@ namespace LibGit2Sharp { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unable to process file '{0}'. This file is not located under the working directory of the repository ('{1}').", - normalizedPath, repo.Info.WorkingDirectory)); + normalizedPath, + repo.Info.WorkingDirectory)); } return normalizedPath.Substring(repo.Info.WorkingDirectory.Length); diff --git a/LibGit2Sharp/RepositoryNotFoundException.cs b/LibGit2Sharp/RepositoryNotFoundException.cs index b07ee913..10333212 100644 --- a/LibGit2Sharp/RepositoryNotFoundException.cs +++ b/LibGit2Sharp/RepositoryNotFoundException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public RepositoryNotFoundException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public RepositoryNotFoundException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -33,8 +31,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public RepositoryNotFoundException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -43,7 +40,6 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected RepositoryNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } } } diff --git a/LibGit2Sharp/RepositoryOperationContext.cs b/LibGit2Sharp/RepositoryOperationContext.cs index 4eb04330..5b67d726 100644 --- a/LibGit2Sharp/RepositoryOperationContext.cs +++ b/LibGit2Sharp/RepositoryOperationContext.cs @@ -20,8 +20,7 @@ /// The URL that this operation will download from. internal RepositoryOperationContext(string repositoryPath, string remoteUrl) : this(repositoryPath, remoteUrl, string.Empty, string.Empty, 0) - { - } + { } /// /// Constructor suitable for use on the sub repositories. @@ -31,10 +30,11 @@ /// The path to the super repository. /// The logical name of this submodule. /// The depth of this sub repository from the original super repository. - internal RepositoryOperationContext(string repositoryPath, - string remoteUrl, - string parentRepositoryPath, - string submoduleName, int recursionDepth) + internal RepositoryOperationContext( + string repositoryPath, + string remoteUrl, + string parentRepositoryPath, + string submoduleName, int recursionDepth) { RepositoryPath = repositoryPath; RemoteUrl = remoteUrl; diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs index 56a1c8dd..8a6b2e0f 100644 --- a/LibGit2Sharp/RepositoryStatus.cs +++ b/LibGit2Sharp/RepositoryStatus.cs @@ -34,17 +34,17 @@ namespace LibGit2Sharp private static IDictionary> Build() { return new Dictionary> - { - { FileStatus.NewInWorkdir, (rs, s) => rs.untracked.Add(s) }, - { FileStatus.ModifiedInWorkdir, (rs, s) => rs.modified.Add(s) }, - { FileStatus.DeletedFromWorkdir, (rs, s) => rs.missing.Add(s) }, - { FileStatus.NewInIndex, (rs, s) => rs.added.Add(s) }, - { FileStatus.ModifiedInIndex, (rs, s) => rs.staged.Add(s) }, - { FileStatus.DeletedFromIndex, (rs, s) => rs.removed.Add(s) }, - { FileStatus.RenamedInIndex, (rs, s) => rs.renamedInIndex.Add(s) }, - { FileStatus.Ignored, (rs, s) => rs.ignored.Add(s) }, - { FileStatus.RenamedInWorkdir, (rs, s) => rs.renamedInWorkDir.Add(s) }, - }; + { + { FileStatus.NewInWorkdir, (rs, s) => rs.untracked.Add(s) }, + { FileStatus.ModifiedInWorkdir, (rs, s) => rs.modified.Add(s) }, + { FileStatus.DeletedFromWorkdir, (rs, s) => rs.missing.Add(s) }, + { FileStatus.NewInIndex, (rs, s) => rs.added.Add(s) }, + { FileStatus.ModifiedInIndex, (rs, s) => rs.staged.Add(s) }, + { FileStatus.DeletedFromIndex, (rs, s) => rs.removed.Add(s) }, + { FileStatus.RenamedInIndex, (rs, s) => rs.renamedInIndex.Add(s) }, + { FileStatus.Ignored, (rs, s) => rs.ignored.Add(s) }, + { FileStatus.RenamedInWorkdir, (rs, s) => rs.renamedInWorkDir.Add(s) }, + }; } /// @@ -151,23 +151,23 @@ namespace LibGit2Sharp if ((gitStatus & FileStatus.RenamedInIndex) == FileStatus.RenamedInIndex) { - headToIndexRenameDetails = new RenameDetails( - LaxFilePathMarshaler.FromNative(deltaHeadToIndex.OldFile.Path).Native, - LaxFilePathMarshaler.FromNative(deltaHeadToIndex.NewFile.Path).Native, - (int)deltaHeadToIndex.Similarity); + headToIndexRenameDetails = + new RenameDetails(LaxFilePathMarshaler.FromNative(deltaHeadToIndex.OldFile.Path).Native, + LaxFilePathMarshaler.FromNative(deltaHeadToIndex.NewFile.Path).Native, + (int)deltaHeadToIndex.Similarity); } if ((gitStatus & FileStatus.RenamedInWorkdir) == FileStatus.RenamedInWorkdir) { - indexToWorkDirRenameDetails = new RenameDetails( - LaxFilePathMarshaler.FromNative(deltaIndexToWorkDir.OldFile.Path).Native, - LaxFilePathMarshaler.FromNative(deltaIndexToWorkDir.NewFile.Path).Native, - (int)deltaIndexToWorkDir.Similarity); + indexToWorkDirRenameDetails = + new RenameDetails(LaxFilePathMarshaler.FromNative(deltaIndexToWorkDir.OldFile.Path).Native, + LaxFilePathMarshaler.FromNative(deltaIndexToWorkDir.NewFile.Path).Native, + (int)deltaIndexToWorkDir.Similarity); } - var filePath = (deltaIndexToWorkDir != null) ? - LaxFilePathMarshaler.FromNative(deltaIndexToWorkDir.NewFile.Path).Native : - LaxFilePathMarshaler.FromNative(deltaHeadToIndex.NewFile.Path).Native; + var filePath = (deltaIndexToWorkDir != null) + ? LaxFilePathMarshaler.FromNative(deltaIndexToWorkDir.NewFile.Path).Native + : LaxFilePathMarshaler.FromNative(deltaHeadToIndex.NewFile.Path).Native; StatusEntry statusEntry = new StatusEntry(filePath, gitStatus, headToIndexRenameDetails, indexToWorkDirRenameDetails); @@ -323,12 +323,15 @@ namespace LibGit2Sharp { get { - return string.Format( - CultureInfo.InvariantCulture, - "+{0} ~{1} -{2} | +{3} ~{4} -{5} | i{6}", - Added.Count(), Staged.Count(), Removed.Count(), - Untracked.Count(), Modified.Count(), Missing.Count(), - Ignored.Count()); + return string.Format(CultureInfo.InvariantCulture, + "+{0} ~{1} -{2} | +{3} ~{4} -{5} | i{6}", + Added.Count(), + Staged.Count(), + Removed.Count(), + Untracked.Count(), + Modified.Count(), + Missing.Count(), + Ignored.Count()); } } } diff --git a/LibGit2Sharp/RevertOptions.cs b/LibGit2Sharp/RevertOptions.cs index c57794f0..882afb08 100644 --- a/LibGit2Sharp/RevertOptions.cs +++ b/LibGit2Sharp/RevertOptions.cs @@ -10,8 +10,7 @@ /// By default the revert will be committed if there are no conflicts. /// public RevertOptions() - { - } + { } /// /// When reverting a merge commit, the parent number to consider as diff --git a/LibGit2Sharp/SmartSubtransport.cs b/LibGit2Sharp/SmartSubtransport.cs index 1203cedf..f7d2d755 100644 --- a/LibGit2Sharp/SmartSubtransport.cs +++ b/LibGit2Sharp/SmartSubtransport.cs @@ -60,8 +60,7 @@ namespace LibGit2Sharp /// Override this method to add additional cleanup steps to your subclass. Be sure to call base.Close(). /// protected virtual void Close() - { - } + { } /// /// Invoked by libgit2 when this subtransport is being freed. Override this method to add additional diff --git a/LibGit2Sharp/SmartSubtransportRegistration.cs b/LibGit2Sharp/SmartSubtransportRegistration.cs index 8247b023..8fa403d3 100644 --- a/LibGit2Sharp/SmartSubtransportRegistration.cs +++ b/LibGit2Sharp/SmartSubtransportRegistration.cs @@ -27,23 +27,11 @@ namespace LibGit2Sharp /// /// The URI scheme (eg "http") for this transport. /// - public string Scheme - { - get; - private set; - } + public string Scheme { get; private set; } - internal IntPtr RegistrationPointer - { - get; - private set; - } + internal IntPtr RegistrationPointer { get; private set; } - internal IntPtr FunctionPointer - { - get; - private set; - } + internal IntPtr FunctionPointer { get; private set; } private IntPtr CreateRegistrationPointer() { diff --git a/LibGit2Sharp/SmartSubtransportStream.cs b/LibGit2Sharp/SmartSubtransportStream.cs index 7048370e..b5cb21c0 100644 --- a/LibGit2Sharp/SmartSubtransportStream.cs +++ b/LibGit2Sharp/SmartSubtransportStream.cs @@ -46,27 +46,19 @@ namespace LibGit2Sharp /// /// Requests that the stream write the next length bytes of the stream to the provided Stream object. /// - public abstract int Read( - Stream dataStream, - long length, - out long bytesRead); + public abstract int Read(Stream dataStream, long length, out long bytesRead); /// /// Requests that the stream write the first length bytes of the provided Stream object to the stream. /// - public abstract int Write( - Stream dataStream, - long length); + public abstract int Write(Stream dataStream, long length); /// /// The smart transport that this stream represents a connection over. /// public virtual SmartSubtransport SmartTransport { - get - { - return this.subtransport; - } + get { return this.subtransport; } } private SmartSubtransport subtransport; @@ -112,12 +104,15 @@ namespace LibGit2Sharp { bytes_read = UIntPtr.Zero; - SmartSubtransportStream transportStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitSmartSubtransportStream.GCHandleOffset)).Target as SmartSubtransportStream; + SmartSubtransportStream transportStream = + GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitSmartSubtransportStream.GCHandleOffset)).Target as SmartSubtransportStream; if (transportStream != null && buf_size.ToUInt64() < (ulong)long.MaxValue) { - using (UnmanagedMemoryStream memoryStream = new UnmanagedMemoryStream((byte*)buffer, 0, (long)buf_size.ToUInt64(), FileAccess.ReadWrite)) + using (UnmanagedMemoryStream memoryStream = new UnmanagedMemoryStream((byte*)buffer, 0, + (long)buf_size.ToUInt64(), + FileAccess.ReadWrite)) { try { @@ -139,15 +134,12 @@ namespace LibGit2Sharp return (int)GitErrorCode.Error; } - private static unsafe int Write( - IntPtr stream, - IntPtr buffer, - UIntPtr len) + private static unsafe int Write(IntPtr stream, IntPtr buffer, UIntPtr len) { - SmartSubtransportStream transportStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitSmartSubtransportStream.GCHandleOffset)).Target as SmartSubtransportStream; + SmartSubtransportStream transportStream = + GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitSmartSubtransportStream.GCHandleOffset)).Target as SmartSubtransportStream; - if (transportStream != null && - len.ToUInt64() < (ulong)long.MaxValue) + if (transportStream != null && len.ToUInt64() < (ulong)long.MaxValue) { long length = (long)len.ToUInt64(); @@ -167,10 +159,10 @@ namespace LibGit2Sharp return (int)GitErrorCode.Error; } - private static void Free( - IntPtr stream) + private static void Free(IntPtr stream) { - SmartSubtransportStream transportStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitSmartSubtransportStream.GCHandleOffset)).Target as SmartSubtransportStream; + SmartSubtransportStream transportStream = + GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitSmartSubtransportStream.GCHandleOffset)).Target as SmartSubtransportStream; if (transportStream != null) { diff --git a/LibGit2Sharp/StashCollection.cs b/LibGit2Sharp/StashCollection.cs index 4cae6370..5fe775eb 100644 --- a/LibGit2Sharp/StashCollection.cs +++ b/LibGit2Sharp/StashCollection.cs @@ -42,8 +42,9 @@ namespace LibGit2Sharp /// An object that can be used to iterate through the collection. public virtual IEnumerator GetEnumerator() { - return Proxy.git_stash_foreach(repo.Handle, - (index, message, commitId) => new Stash(repo, new ObjectId(commitId), index)).GetEnumerator(); + Func resultSelector = (index, message, commitId) => new Stash(repo, new ObjectId(commitId), index); + + return Proxy.git_stash_foreach(repo.Handle, resultSelector).GetEnumerator(); } /// @@ -69,10 +70,15 @@ namespace LibGit2Sharp throw new ArgumentOutOfRangeException("index", "The passed index must be a positive integer."); } - GitObject stashCommit = repo.Lookup( - string.Format(CultureInfo.InvariantCulture, "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); + return stashCommit == null + ? null + : new Stash(repo, stashCommit.Id, index); } } @@ -235,8 +241,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } } diff --git a/LibGit2Sharp/StatusEntry.cs b/LibGit2Sharp/StatusEntry.cs index 1d62a098..7008712c 100644 --- a/LibGit2Sharp/StatusEntry.cs +++ b/LibGit2Sharp/StatusEntry.cs @@ -123,8 +123,9 @@ namespace LibGit2Sharp if ((State & FileStatus.RenamedInIndex) == FileStatus.RenamedInIndex || (State & FileStatus.RenamedInWorkdir) == FileStatus.RenamedInWorkdir) { - string oldFilePath = ((State & FileStatus.RenamedInIndex) == FileStatus.RenamedInIndex) ? - HeadToIndexRenameDetails.OldFilePath : IndexToWorkDirRenameDetails.OldFilePath; + string oldFilePath = ((State & FileStatus.RenamedInIndex) != 0) + ? HeadToIndexRenameDetails.OldFilePath + : IndexToWorkDirRenameDetails.OldFilePath; return string.Format(CultureInfo.InvariantCulture, "{0}: {1} -> {2}", State, oldFilePath, FilePath); } diff --git a/LibGit2Sharp/Submodule.cs b/LibGit2Sharp/Submodule.cs index d832609a..2b79a69d 100644 --- a/LibGit2Sharp/Submodule.cs +++ b/LibGit2Sharp/Submodule.cs @@ -151,8 +151,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "{0} => {1}", Name, Url); + return string.Format(CultureInfo.InvariantCulture, "{0} => {1}", Name, Url); } } diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index 4c9a61fe..bc7aa470 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -41,10 +41,9 @@ namespace LibGit2Sharp { Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return Lookup(name, handle => - new Submodule(repo, name, - Proxy.git_submodule_path(handle), - Proxy.git_submodule_url(handle))); + return Lookup(name, handle => new Submodule(repo, name, + Proxy.git_submodule_path(handle), + Proxy.git_submodule_url(handle))); } } @@ -63,9 +62,9 @@ namespace LibGit2Sharp { if (handle == null) { - throw new NotFoundException(string.Format( - CultureInfo.InvariantCulture, - "Submodule lookup failed for '{0}'.", name)); + throw new NotFoundException(string.Format(CultureInfo.InvariantCulture, + "Submodule lookup failed for '{0}'.", + name)); } Proxy.git_submodule_init(handle, overwrite); @@ -91,9 +90,9 @@ namespace LibGit2Sharp { if (handle == null) { - throw new NotFoundException(string.Format( - CultureInfo.InvariantCulture, - "Submodule lookup failed for '{0}'.", name)); + throw new NotFoundException(string.Format(CultureInfo.InvariantCulture, + "Submodule lookup failed for '{0}'.", + name)); } using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options)) @@ -138,14 +137,15 @@ namespace LibGit2Sharp internal bool TryStage(string relativePath, bool writeIndex) { - return Lookup(relativePath, handle => - { - if (handle == null) - return false; - - Proxy.git_submodule_add_to_index(handle, writeIndex); - return true; - }); + return Lookup(relativePath, + handle => + { + if (handle == null) + return false; + + Proxy.git_submodule_add_to_index(handle, writeIndex); + return true; + }); } internal T Lookup(string name, Func selector, bool throwIfNotFound = false) @@ -171,8 +171,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } } diff --git a/LibGit2Sharp/SymbolicReference.cs b/LibGit2Sharp/SymbolicReference.cs index 5bb47531..f4ad5bd8 100644 --- a/LibGit2Sharp/SymbolicReference.cs +++ b/LibGit2Sharp/SymbolicReference.cs @@ -45,9 +45,12 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0} => {1} => \"{2}\"", - CanonicalName, TargetIdentifier, - (Target != null) ? Target.TargetIdentifier : "?"); + "{0} => {1} => \"{2}\"", + CanonicalName, + TargetIdentifier, + (Target != null) + ? Target.TargetIdentifier + : "?"); } } } diff --git a/LibGit2Sharp/Tag.cs b/LibGit2Sharp/Tag.cs index 35e02120..cb243634 100644 --- a/LibGit2Sharp/Tag.cs +++ b/LibGit2Sharp/Tag.cs @@ -13,8 +13,7 @@ internal Tag(Repository repo, Reference reference, string canonicalName) : base(repo, reference, _ => canonicalName) - { - } + { } /// /// Gets the optional information associated to this tag. diff --git a/LibGit2Sharp/TagAnnotation.cs b/LibGit2Sharp/TagAnnotation.cs index 3028cfc1..96ef697c 100644 --- a/LibGit2Sharp/TagAnnotation.cs +++ b/LibGit2Sharp/TagAnnotation.cs @@ -23,8 +23,12 @@ namespace LibGit2Sharp : base(repo, id) { lazyName = GitObjectLazyGroup.Singleton(repo, id, Proxy.git_tag_name); - lazyTarget = GitObjectLazyGroup.Singleton(repo, id, - obj => BuildFrom(repo, Proxy.git_tag_target_id(obj), Proxy.git_tag_target_type(obj), null)); + lazyTarget = GitObjectLazyGroup.Singleton(repo, + id, + obj => BuildFrom(repo, + Proxy.git_tag_target_id(obj), + Proxy.git_tag_target_type(obj), + null)); group = new GitObjectLazyGroup(repo, id); lazyTagger = group.AddLazy(Proxy.git_tag_tagger); diff --git a/LibGit2Sharp/TagCollection.cs b/LibGit2Sharp/TagCollection.cs index 4587d39b..8bd9168b 100644 --- a/LibGit2Sharp/TagCollection.cs +++ b/LibGit2Sharp/TagCollection.cs @@ -237,8 +237,7 @@ namespace LibGit2Sharp { get { - return string.Format(CultureInfo.InvariantCulture, - "Count = {0}", this.Count()); + return string.Format(CultureInfo.InvariantCulture, "Count = {0}", this.Count()); } } } diff --git a/LibGit2Sharp/TarArchiver.cs b/LibGit2Sharp/TarArchiver.cs index 0710734f..5b2d753e 100644 --- a/LibGit2Sharp/TarArchiver.cs +++ b/LibGit2Sharp/TarArchiver.cs @@ -29,11 +29,23 @@ namespace LibGit2Sharp } // Store the sha in the pax_global_header - using (var stream = new MemoryStream(Encoding.ASCII.GetBytes( - string.Format(CultureInfo.InvariantCulture, "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); + writer.Write("pax_global_header", + stream, modificationTime, + "666".OctalToInt32(), + "0", + "0", + 'g', + "root", + "root", + "0", + "0", + oid.Sha, + false); } } @@ -43,27 +55,55 @@ namespace LibGit2Sharp { case Mode.GitLink: case Mode.Directory: - writer.Write(path + "/", null, modificationTime, "775".OctalToInt32(), - "0", "0", '5', "root", "root", "0", "0", entry.TargetId.Sha, false); + writer.Write(path + "/", + null, + modificationTime, + "775".OctalToInt32(), + "0", + "0", + '5', + "root", + "root", + "0", + "0", + entry.TargetId.Sha, + false); break; case Mode.ExecutableFile: case Mode.NonExecutableFile: case Mode.NonExecutableGroupWritableFile: - var blob = ((Blob) entry.Target); + var blob = ((Blob)entry.Target); - WriteStream(path, entry, modificationTime, - () => blob.IsBinary ? blob.GetContentStream() : blob.GetContentStream(new FilteringOptions(path))); + WriteStream(path, + entry, + modificationTime, + () => blob.IsBinary + ? blob.GetContentStream() + : blob.GetContentStream(new FilteringOptions(path))); break; case Mode.SymbolicLink: using (Stream contentStream = ((Blob)entry.Target).GetContentStream(new FilteringOptions(path))) { - writer.Write(path, contentStream, modificationTime, "777".OctalToInt32(), - "0", "0", '2', "root", "root", "0", "0", entry.TargetId.Sha, true); + writer.Write(path, + contentStream, + modificationTime, + "777".OctalToInt32(), + "0", + "0", + '2', + "root", + "root", + "0", + "0", + entry.TargetId.Sha, + true); } break; default: - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, "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)); } } @@ -71,9 +111,21 @@ namespace LibGit2Sharp { using (Stream contentStream = streamer()) { - writer.Write(path, contentStream, modificationTime, - (entry.Mode == Mode.ExecutableFile) ? "775".OctalToInt32() : "664".OctalToInt32(), - "0", "0", '0', "root", "root", "0", "0", entry.TargetId.Sha, false); + writer.Write(path, + contentStream, + modificationTime, + (entry.Mode == Mode.ExecutableFile) + ? "775".OctalToInt32() + : "664".OctalToInt32(), + "0", + "0", + '0', + "root", + "root", + "0", + "0", + entry.TargetId.Sha, + false); } } diff --git a/LibGit2Sharp/TransferProgress.cs b/LibGit2Sharp/TransferProgress.cs index 29638103..984c1741 100644 --- a/LibGit2Sharp/TransferProgress.cs +++ b/LibGit2Sharp/TransferProgress.cs @@ -31,10 +31,7 @@ namespace LibGit2Sharp /// public virtual int TotalObjects { - get - { - return (int) gitTransferProgress.total_objects; - } + get { return (int)gitTransferProgress.total_objects; } } /// @@ -42,10 +39,7 @@ namespace LibGit2Sharp /// public virtual int IndexedObjects { - get - { - return (int) gitTransferProgress.indexed_objects; - } + get { return (int)gitTransferProgress.indexed_objects; } } /// @@ -53,10 +47,7 @@ namespace LibGit2Sharp /// public virtual int ReceivedObjects { - get - { - return (int) gitTransferProgress.received_objects; - } + get { return (int)gitTransferProgress.received_objects; } } /// @@ -64,10 +55,7 @@ namespace LibGit2Sharp /// public virtual long ReceivedBytes { - get - { - return (long) gitTransferProgress.received_bytes; - } + get { return (long)gitTransferProgress.received_bytes; } } private string DebuggerDisplay @@ -75,7 +63,10 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0}/{1}, {2} bytes", ReceivedObjects, TotalObjects, ReceivedBytes); + "{0}/{1}, {2} bytes", + ReceivedObjects, + TotalObjects, + ReceivedBytes); } } } diff --git a/LibGit2Sharp/Tree.cs b/LibGit2Sharp/Tree.cs index c70eb9ee..9ef5f1e8 100644 --- a/LibGit2Sharp/Tree.cs +++ b/LibGit2Sharp/Tree.cs @@ -107,7 +107,9 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "{0}, Count = {1}", Id.ToString(7), Count); + "{0}, Count = {1}", + Id.ToString(7), + Count); } } } diff --git a/LibGit2Sharp/TreeChanges.cs b/LibGit2Sharp/TreeChanges.cs index ae3fd38c..0e0d54c0 100644 --- a/LibGit2Sharp/TreeChanges.cs +++ b/LibGit2Sharp/TreeChanges.cs @@ -32,16 +32,16 @@ namespace LibGit2Sharp private static IDictionary> Build() { return new Dictionary> - { - { ChangeKind.Modified, (de, d) => de.modified.Add(d) }, - { ChangeKind.Deleted, (de, d) => de.deleted.Add(d) }, - { ChangeKind.Added, (de, d) => de.added.Add(d) }, - { ChangeKind.TypeChanged, (de, d) => de.typeChanged.Add(d) }, - { ChangeKind.Unmodified, (de, d) => de.unmodified.Add(d) }, - { ChangeKind.Renamed, (de, d) => de.renamed.Add(d) }, - { ChangeKind.Copied, (de, d) => de.copied.Add(d) }, - { ChangeKind.Conflicted, (de, d) => de.conflicted.Add(d) }, - }; + { + { ChangeKind.Modified, (de, d) => de.modified.Add(d) }, + { ChangeKind.Deleted, (de, d) => de.deleted.Add(d) }, + { ChangeKind.Added, (de, d) => de.added.Add(d) }, + { ChangeKind.TypeChanged, (de, d) => de.typeChanged.Add(d) }, + { ChangeKind.Unmodified, (de, d) => de.unmodified.Add(d) }, + { ChangeKind.Renamed, (de, d) => de.renamed.Add(d) }, + { ChangeKind.Copied, (de, d) => de.copied.Add(d) }, + { ChangeKind.Conflicted, (de, d) => de.conflicted.Add(d) }, + }; } /// @@ -161,9 +161,13 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "+{0} ~{1} -{2} \u00B1{3} R{4} C{5}", - Added.Count(), Modified.Count(), Deleted.Count(), - TypeChanged.Count(), Renamed.Count(), Copied.Count()); + "+{0} ~{1} -{2} \u00B1{3} R{4} C{5}", + Added.Count(), + Modified.Count(), + Deleted.Count(), + TypeChanged.Count(), + Renamed.Count(), + Copied.Count()); } } } diff --git a/LibGit2Sharp/TreeDefinition.cs b/LibGit2Sharp/TreeDefinition.cs index 8db64a10..8f016c20 100644 --- a/LibGit2Sharp/TreeDefinition.cs +++ b/LibGit2Sharp/TreeDefinition.cs @@ -134,9 +134,12 @@ namespace LibGit2Sharp if (treeEntryDefinition is TransientTreeTreeEntryDefinition) { 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)); + "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 segments = ExtractPosixLeadingSegment(targetTreeEntryPath); @@ -370,7 +373,9 @@ namespace LibGit2Sharp if (segments.Item2 != null) { TreeDefinition td = RetrieveOrBuildTreeDefinition(segments.Item1, false); - return td == null ? null : td[segments.Item2]; + return td == null + ? null + : td[segments.Item2]; } TreeEntryDefinition treeEntryDefinition; diff --git a/LibGit2Sharp/TreeEntry.cs b/LibGit2Sharp/TreeEntry.cs index 54dd9599..dd264755 100644 --- a/LibGit2Sharp/TreeEntry.cs +++ b/LibGit2Sharp/TreeEntry.cs @@ -84,10 +84,9 @@ namespace LibGit2Sharp return GitObject.BuildFrom(repo, targetOid, TargetType.ToGitObjectType(), Path); default: - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, - "TreeEntry target of type '{0}' is not supported.", - TargetType)); + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, + "TreeEntry target of type '{0}' is not supported.", + TargetType)); } } diff --git a/LibGit2Sharp/TreeEntryChanges.cs b/LibGit2Sharp/TreeEntryChanges.cs index e731de79..f683a312 100644 --- a/LibGit2Sharp/TreeEntryChanges.cs +++ b/LibGit2Sharp/TreeEntryChanges.cs @@ -94,8 +94,11 @@ namespace LibGit2Sharp get { return string.Format(CultureInfo.InvariantCulture, - "Path = {0}, File {1}", - !string.IsNullOrEmpty(Path) ? Path : OldPath, Status); + "Path = {0}, File {1}", + !string.IsNullOrEmpty(Path) + ? Path + : OldPath, + Status); } } } diff --git a/LibGit2Sharp/TreeEntryDefinition.cs b/LibGit2Sharp/TreeEntryDefinition.cs index c0eb979d..b89c5930 100644 --- a/LibGit2Sharp/TreeEntryDefinition.cs +++ b/LibGit2Sharp/TreeEntryDefinition.cs @@ -19,8 +19,7 @@ namespace LibGit2Sharp /// Needed for mocking purposes. /// protected TreeEntryDefinition() - { - } + { } /// /// Gets file mode. @@ -45,23 +44,23 @@ namespace LibGit2Sharp internal static TreeEntryDefinition From(TreeEntry treeEntry) { return new TreeEntryDefinition - { - Mode = treeEntry.Mode, - TargetType = treeEntry.TargetType, - TargetId = treeEntry.TargetId, - target = new Lazy(() => treeEntry.Target) - }; + { + Mode = treeEntry.Mode, + TargetType = treeEntry.TargetType, + TargetId = treeEntry.TargetId, + target = new Lazy(() => treeEntry.Target) + }; } internal static TreeEntryDefinition From(Blob blob, Mode mode) { return new TreeEntryDefinition - { - Mode = mode, - TargetType = TreeEntryTargetType.Blob, - TargetId = blob.Id, - target = new Lazy(() => blob) - }; + { + Mode = mode, + TargetType = TreeEntryTargetType.Blob, + TargetId = blob.Id, + target = new Lazy(() => blob) + }; } internal static TreeEntryDefinition TransientBlobFrom(string filePath, Mode mode) @@ -69,32 +68,32 @@ namespace LibGit2Sharp Ensure.ArgumentConformsTo(mode, m => m.HasAny(BlobModes), "mode"); return new TransientBlobTreeEntryDefinition - { - Builder = odb => odb.CreateBlob(filePath), - Mode = mode, - }; + { + Builder = odb => odb.CreateBlob(filePath), + Mode = mode, + }; } internal static TreeEntryDefinition From(ObjectId objectId) { return new TreeEntryDefinition - { - Mode = Mode.GitLink, - TargetType = TreeEntryTargetType.GitLink, - TargetId = objectId, - target = new Lazy(() => { throw new InvalidOperationException("Shouldn't be necessary."); }), - }; + { + Mode = Mode.GitLink, + TargetType = TreeEntryTargetType.GitLink, + TargetId = objectId, + target = new Lazy(() => { throw new InvalidOperationException("Shouldn't be necessary."); }), + }; } internal static TreeEntryDefinition From(Tree tree) { return new TreeEntryDefinition - { - Mode = Mode.Directory, - TargetType = TreeEntryTargetType.Tree, - TargetId = tree.Id, - target = new Lazy(() => tree) - }; + { + Mode = Mode.Directory, + TargetType = TreeEntryTargetType.Tree, + TargetId = tree.Id, + target = new Lazy(() => tree) + }; } /// diff --git a/LibGit2Sharp/TreeEntryTargetType.cs b/LibGit2Sharp/TreeEntryTargetType.cs index a4e54d73..46ceb7d9 100644 --- a/LibGit2Sharp/TreeEntryTargetType.cs +++ b/LibGit2Sharp/TreeEntryTargetType.cs @@ -38,8 +38,9 @@ namespace LibGit2Sharp return GitObjectType.Blob; default: - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, "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/UnbornBranchException.cs b/LibGit2Sharp/UnbornBranchException.cs index ac2b1ee2..0d553e3d 100644 --- a/LibGit2Sharp/UnbornBranchException.cs +++ b/LibGit2Sharp/UnbornBranchException.cs @@ -15,8 +15,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public UnbornBranchException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -24,8 +23,7 @@ namespace LibGit2Sharp /// A message that describes the error. public UnbornBranchException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -35,8 +33,7 @@ namespace LibGit2Sharp /// An object array that contains zero or more objects to format. public UnbornBranchException(CultureInfo cultureInfo, string format, params object[] args) : base(String.Format(cultureInfo, format, args)) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -45,8 +42,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public UnbornBranchException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -55,7 +51,6 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected UnbornBranchException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } } } diff --git a/LibGit2Sharp/UnmatchedPathException.cs b/LibGit2Sharp/UnmatchedPathException.cs index e63b3514..ae5f3386 100644 --- a/LibGit2Sharp/UnmatchedPathException.cs +++ b/LibGit2Sharp/UnmatchedPathException.cs @@ -13,8 +13,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public UnmatchedPathException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -22,8 +21,7 @@ namespace LibGit2Sharp /// A message that describes the error. public UnmatchedPathException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -32,8 +30,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public UnmatchedPathException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -42,7 +39,6 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected UnmatchedPathException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } } } diff --git a/LibGit2Sharp/UnmergedIndexEntriesException.cs b/LibGit2Sharp/UnmergedIndexEntriesException.cs index f221b4a6..6cfa020c 100644 --- a/LibGit2Sharp/UnmergedIndexEntriesException.cs +++ b/LibGit2Sharp/UnmergedIndexEntriesException.cs @@ -15,8 +15,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public UnmergedIndexEntriesException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -24,8 +23,7 @@ namespace LibGit2Sharp /// A message that describes the error. public UnmergedIndexEntriesException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -34,8 +32,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public UnmergedIndexEntriesException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -44,12 +41,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected UnmergedIndexEntriesException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal UnmergedIndexEntriesException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/UserCanceledException.cs b/LibGit2Sharp/UserCanceledException.cs index fdc03396..45ab75f3 100644 --- a/LibGit2Sharp/UserCanceledException.cs +++ b/LibGit2Sharp/UserCanceledException.cs @@ -14,8 +14,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the class. /// public UserCancelledException() - { - } + { } /// /// Initializes a new instance of the class with a specified error message. @@ -23,8 +22,7 @@ namespace LibGit2Sharp /// A message that describes the error. public UserCancelledException(string message) : base(message) - { - } + { } /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. @@ -33,8 +31,7 @@ namespace LibGit2Sharp /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. public UserCancelledException(string message, Exception innerException) : base(message, innerException) - { - } + { } /// /// Initializes a new instance of the class with a serialized data. @@ -43,12 +40,10 @@ namespace LibGit2Sharp /// The that contains contextual information about the source or destination. protected UserCancelledException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + { } internal UserCancelledException(string message, GitErrorCode code, GitErrorCategory category) : base(message, code, category) - { - } + { } } } diff --git a/LibGit2Sharp/Version.cs b/LibGit2Sharp/Version.cs index fbc6ef89..4a155dcb 100644 --- a/LibGit2Sharp/Version.cs +++ b/LibGit2Sharp/Version.cs @@ -46,10 +46,7 @@ namespace LibGit2Sharp /// A enumeration. public virtual BuiltInFeatures Features { - get - { - return Proxy.git_libgit2_features(); - } + get { return Proxy.git_libgit2_features(); } } /// @@ -92,14 +89,13 @@ namespace LibGit2Sharp { string features = Features.ToString(); - return string.Format( - CultureInfo.InvariantCulture, - "{0}-{1}-{2} ({3} - {4})", - InformationalVersion, - LibGit2SharpCommitSha, - LibGit2CommitSha, - Platform.ProcessorArchitecture, - features); + return string.Format(CultureInfo.InvariantCulture, + "{0}-{1}-{2} ({3} - {4})", + InformationalVersion, + LibGit2SharpCommitSha, + LibGit2CommitSha, + Platform.ProcessorArchitecture, + features); } private string ReadContentFromResource(Assembly assembly, string partialResourceName) -- cgit v1.2.3