Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2015-06-11 18:49:47 +0300
committernulltoken <emeric.fermas@gmail.com>2015-06-11 18:49:47 +0300
commit1359cc592c18bf83ccc658c7d236eb3e9d688816 (patch)
tree2a8aff83778d0df43a9fde282ce5fedccfe8485b
parente10e22388d454f7a45af2b632068a6c07de1e199 (diff)
parent611e4123fa078d72111e89c57f49a3fc3fe61205 (diff)
Merge pull request #1090 from libgit2/ntk/coverity
Let's (try to) make Coverity's job easier
-rw-r--r--LibGit2Sharp.Tests/FilterFixture.cs2
-rw-r--r--LibGit2Sharp.Tests/FilterSubstitutionCipherFixture.cs6
-rw-r--r--LibGit2Sharp/Core/Ensure.cs39
-rw-r--r--LibGit2Sharp/Repository.cs7
-rw-r--r--LibGit2Sharp/RepositoryExtensions.cs2
-rw-r--r--README.md14
6 files changed, 31 insertions, 39 deletions
diff --git a/LibGit2Sharp.Tests/FilterFixture.cs b/LibGit2Sharp.Tests/FilterFixture.cs
index 1de81595..b0480256 100644
--- a/LibGit2Sharp.Tests/FilterFixture.cs
+++ b/LibGit2Sharp.Tests/FilterFixture.cs
@@ -304,7 +304,7 @@ namespace LibGit2Sharp.Tests
private static FileInfo CommitFileOnBranch(Repository repo, string branchName, String content)
{
var branch = repo.CreateBranch(branchName);
- repo.Checkout(branch.Name);
+ repo.Checkout(branch.FriendlyName);
FileInfo expectedPath = StageNewFile(repo, content);
repo.Commit("Commit");
diff --git a/LibGit2Sharp.Tests/FilterSubstitutionCipherFixture.cs b/LibGit2Sharp.Tests/FilterSubstitutionCipherFixture.cs
index b2610a57..1ef2f47a 100644
--- a/LibGit2Sharp.Tests/FilterSubstitutionCipherFixture.cs
+++ b/LibGit2Sharp.Tests/FilterSubstitutionCipherFixture.cs
@@ -35,7 +35,7 @@ namespace LibGit2Sharp.Tests
Assert.Equal(0, filter.SmudgeCalledCount);
var branch = repo.CreateBranch("delete-files");
- repo.Checkout(branch.Name);
+ repo.Checkout(branch.FriendlyName);
DeleteFile(repo, fileName);
@@ -75,7 +75,7 @@ namespace LibGit2Sharp.Tests
Assert.Equal(0, filter.SmudgeCalledCount);
var branch = repo.CreateBranch("delete-files");
- repo.Checkout(branch.Name);
+ repo.Checkout(branch.FriendlyName);
DeleteFile(repo, fileName);
@@ -181,7 +181,7 @@ namespace LibGit2Sharp.Tests
CommitOnBranchAndReturnDatabaseBlob(repo, fileName, decodedInput);
var branch = repo.CreateBranch("delete-files");
- repo.Checkout(branch.Name);
+ repo.Checkout(branch.FriendlyName);
DeleteFile(repo, fileName);
diff --git a/LibGit2Sharp/Core/Ensure.cs b/LibGit2Sharp/Core/Ensure.cs
index b051c850..04303ca3 100644
--- a/LibGit2Sharp/Core/Ensure.cs
+++ b/LibGit2Sharp/Core/Ensure.cs
@@ -250,44 +250,21 @@ namespace LibGit2Sharp.Core
/// <param name="identifier">The <see cref="GitObject"/> identifier to examine.</param>
public static void GitObjectIsNotNull(GitObject gitObject, string identifier)
{
- Func<string, LibGit2SharpException> exceptionBuilder;
-
- if (string.Equals("HEAD", identifier, StringComparison.Ordinal))
- {
- exceptionBuilder = m => new UnbornBranchException(m);
- }
- else
+ if (gitObject != null)
{
- exceptionBuilder = m => new NotFoundException(m);
+ return;
}
- GitObjectIsNotNull(gitObject, identifier, exceptionBuilder);
- }
-
+ var message = string.Format(CultureInfo.InvariantCulture,
+ "No valid git object identified by '{0}' exists in the repository.",
+ identifier);
- /// <summary>
- /// Check that the result of a C call that returns a non-null GitObject
- /// using the default exception builder.
- /// <para>
- /// The native function is expected to return a valid object value.
- /// </para>
- /// </summary>
- /// <param name="gitObject">The <see cref="GitObject"/> to examine.</param>
- /// <param name="identifier">The <see cref="GitObject"/> identifier to examine.</param>
- /// <param name="exceptionBuilder">The builder which constructs an <see cref="LibGit2SharpException"/> from a message.</param>
- public static void GitObjectIsNotNull(
- GitObject gitObject,
- string identifier,
- Func<string, LibGit2SharpException> exceptionBuilder)
- {
- if (gitObject != null)
+ if (string.Equals("HEAD", identifier, StringComparison.Ordinal))
{
- return;
+ throw new UnbornBranchException(message);
}
- throw exceptionBuilder(string.Format(CultureInfo.InvariantCulture,
- "No valid git object identified by '{0}' exists in the repository.",
- identifier));
+ throw new NotFoundException(message);
}
}
}
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index 030a7982..77e928f3 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -1006,14 +1006,17 @@ namespace LibGit2Sharp
Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, "committishOrBranchSpec");
Ensure.ArgumentNotNull(paths, "paths");
+ var listOfPaths = paths.ToList();
+
// If there are no paths, then there is nothing to do.
- if (!paths.Any())
+ if (listOfPaths.Count == 0)
{
return;
}
Commit commit = LookupCommit(committishOrBranchSpec);
- CheckoutTree(commit.Tree, paths.ToList(), checkoutOptions ?? new CheckoutOptions());
+
+ CheckoutTree(commit.Tree, listOfPaths, checkoutOptions ?? new CheckoutOptions());
}
/// <summary>
diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs
index 922ff82c..57f7b860 100644
--- a/LibGit2Sharp/RepositoryExtensions.cs
+++ b/LibGit2Sharp/RepositoryExtensions.cs
@@ -98,7 +98,7 @@ namespace LibGit2Sharp
{
Commit commit = repository.Head.Tip;
- Ensure.GitObjectIsNotNull(commit, "HEAD", m => new UnbornBranchException(m));
+ Ensure.GitObjectIsNotNull(commit, "HEAD");
return commit;
}
diff --git a/README.md b/README.md
index b3dd52d5..0c0b0fe1 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@
[twitter]: http://twitter.com/libgit2sharp
## Current project build status
+
The CI builds are generously hosted and run on the [Travis][travis] and [AppVeyor][appveyor] infrastructures.
| | Windows (x86/amd64) | Linux/Mac OS X |
@@ -35,9 +36,17 @@ The CI builds are generously hosted and run on the [Travis][travis] and [AppVeyo
| **master** | [![master win][master-win-badge]][master-win] | [![master nix][master-nix-badge]][master-nix] |
| **vNext** | [![vNext win][vNext-win-badge]][vNext-win] | [![vNext nix][vNext-nix-badge]][vNext-nix] |
+The security oriented static code analysis is kindly run through the [Coverity][coverity] service.
+
+| | Analysis result |
+|-------|-----------------|
+| **vNext** | [![coverity][coverity-badge]][coverity-project] |
+
- [travis]: http://travis-ci.org/
+ [travis]: https://travis-ci.org/
[appveyor]: http://appveyor.com/
+ [coverity]: https://scan.coverity.com/
+
[master-win-badge]: https://ci.appveyor.com/api/projects/status/8qxcoqdo9kp7x2w9/branch/master?svg=true
[master-win]: https://ci.appveyor.com/project/libgit2/libgit2sharp/branch/master
[master-nix-badge]: https://travis-ci.org/libgit2/libgit2sharp.svg?branch=master
@@ -47,6 +56,9 @@ The CI builds are generously hosted and run on the [Travis][travis] and [AppVeyo
[vNext-nix-badge]: https://travis-ci.org/libgit2/libgit2sharp.svg?branch=vNext
[vNext-nix]: https://travis-ci.org/libgit2/libgit2sharp/branches
+ [coverity-project]: https://scan.coverity.com/projects/2088
+ [coverity-badge]: https://scan.coverity.com/projects/2088/badge.svg
+
## Quick contributing guide
- Fork and clone locally