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>2013-01-23 14:44:09 +0400
committernulltoken <emeric.fermas@gmail.com>2013-01-23 17:00:42 +0400
commitec04a5706566b448c9084a13616a0a6497f93637 (patch)
tree74b545d662f8188299526181ea74b6f3f74401f3
parenta41d33626920b627573e76d0324d67ade5cd8d43 (diff)
Make Checkout raise proper MergeConflictException
-rw-r--r--LibGit2Sharp.Tests/CheckoutFixture.cs6
-rw-r--r--LibGit2Sharp/Core/Ensure.cs3
-rw-r--r--LibGit2Sharp/Core/GitErrorCode.cs5
-rw-r--r--LibGit2Sharp/MergeConflictException.cs9
4 files changed, 19 insertions, 4 deletions
diff --git a/LibGit2Sharp.Tests/CheckoutFixture.cs b/LibGit2Sharp.Tests/CheckoutFixture.cs
index 0ab18740..97738b49 100644
--- a/LibGit2Sharp.Tests/CheckoutFixture.cs
+++ b/LibGit2Sharp.Tests/CheckoutFixture.cs
@@ -233,7 +233,7 @@ namespace LibGit2Sharp.Tests
// Assert that normal checkout throws exception
// for the conflict.
- Assert.Throws<LibGit2SharpException>(() => repo.Checkout(master.CanonicalName));
+ Assert.Throws<MergeConflictException>(() => repo.Checkout(master.CanonicalName));
// Checkout with force option should succeed.
repo.Checkout(master.CanonicalName, CheckoutOptions.Force, null);
@@ -272,11 +272,11 @@ namespace LibGit2Sharp.Tests
// Assert that checking out master throws
// when there are unstaged commits
- Assert.Throws<LibGit2SharpException>(() => repo.Checkout("master"));
+ Assert.Throws<MergeConflictException>(() => repo.Checkout("master"));
// And when there are staged commits
repo.Index.Stage(fullPath);
- Assert.Throws<LibGit2SharpException>(() => repo.Checkout("master"));
+ Assert.Throws<MergeConflictException>(() => repo.Checkout("master"));
}
}
diff --git a/LibGit2Sharp/Core/Ensure.cs b/LibGit2Sharp/Core/Ensure.cs
index 48031117..dacbe58a 100644
--- a/LibGit2Sharp/Core/Ensure.cs
+++ b/LibGit2Sharp/Core/Ensure.cs
@@ -90,6 +90,9 @@ namespace LibGit2Sharp.Core
case (int)GitErrorCode.UnmergedEntries:
throw new UnmergedIndexEntriesException(errorMessage, (GitErrorCode)result, error.Category);
+ case (int)GitErrorCode.MergeConflict:
+ throw new MergeConflictException(errorMessage, (GitErrorCode)result, error.Category);
+
default:
throw new LibGit2SharpException(errorMessage, (GitErrorCode)result, error.Category);
}
diff --git a/LibGit2Sharp/Core/GitErrorCode.cs b/LibGit2Sharp/Core/GitErrorCode.cs
index 776229e3..0b59fcf5 100644
--- a/LibGit2Sharp/Core/GitErrorCode.cs
+++ b/LibGit2Sharp/Core/GitErrorCode.cs
@@ -56,6 +56,11 @@
InvalidSpecification = -12,
/// <summary>
+ /// A conflicting change has been detected.
+ /// </summary>
+ MergeConflict = -13,
+
+ /// <summary>
/// Skip and passthrough the given ODB backend.
/// </summary>
PassThrough = -30,
diff --git a/LibGit2Sharp/MergeConflictException.cs b/LibGit2Sharp/MergeConflictException.cs
index 1aa98fdb..7ee86b00 100644
--- a/LibGit2Sharp/MergeConflictException.cs
+++ b/LibGit2Sharp/MergeConflictException.cs
@@ -1,10 +1,12 @@
using System;
using System.Runtime.Serialization;
+using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
- /// The exception that is thrown when there is a conflict merging changes.
+ /// The exception that is thrown when a merge cannot be performed because
+ /// of a conflicting change.
/// </summary>
[Serializable]
public class MergeConflictException : LibGit2SharpException
@@ -44,5 +46,10 @@ namespace LibGit2Sharp
: base(info, context)
{
}
+
+ internal MergeConflictException(string message, GitErrorCode code, GitErrorCategory category)
+ : base(message, code, category)
+ {
+ }
}
}