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-12-21 00:37:16 +0400
committernulltoken <emeric.fermas@gmail.com>2013-12-22 00:48:49 +0400
commitc405b0f8c9bcd7c9165d47a096dac8e0cd8f9901 (patch)
treebac84718645759d9fb5a0a4ee71db69ab10b46dd /LibGit2Sharp
parente5a6ad54991ff19aa086f2994b92ebb7c6749e57 (diff)
Deprecate ObjectId.StartsWith(byte[], int)
Diffstat (limited to 'LibGit2Sharp')
-rw-r--r--LibGit2Sharp/ObjectId.cs29
1 files changed, 23 insertions, 6 deletions
diff --git a/LibGit2Sharp/ObjectId.cs b/LibGit2Sharp/ObjectId.cs
index 9b634294..00454347 100644
--- a/LibGit2Sharp/ObjectId.cs
+++ b/LibGit2Sharp/ObjectId.cs
@@ -231,13 +231,13 @@ namespace LibGit2Sharp
return bytes;
}
- internal static string ToString(byte[] id, int len)
+ internal static string ToString(byte[] id, int lengthInNibbles)
{
// Inspired from http://stackoverflow.com/questions/623104/c-byte-to-hex-string/3974535#3974535
- var c = new char[len];
+ var c = new char[lengthInNibbles];
- for (int i = 0; i < (len & -2); i++)
+ for (int i = 0; i < (lengthInNibbles & -2); i++)
{
int index0 = i >> 1;
var b = ((byte)(id[index0] >> 4));
@@ -247,11 +247,11 @@ namespace LibGit2Sharp
c[i] = hexDigits[b];
}
- if ((len & 1) == 1)
+ if ((lengthInNibbles & 1) == 1)
{
- int index0 = len >> 1;
+ int index0 = lengthInNibbles >> 1;
var b = ((byte)(id[index0] >> 4));
- c[len - 1] = hexDigits[b];
+ c[lengthInNibbles - 1] = hexDigits[b];
}
return new string(c);
@@ -312,6 +312,7 @@ namespace LibGit2Sharp
/// <param name="rawId">The byte array to compare the <see cref="ObjectId"/> against.</param>
/// <param name="len">The number of nibbles from <paramref name="rawId"/> </param>
/// <returns></returns>
+ [Obsolete("This method will be removed in the next release. Please use one of the StartsWith(string) overload instead.")]
public bool StartsWith(byte[] rawId, int len)
{
Ensure.ArgumentNotNull(rawId, "rawId");
@@ -351,5 +352,21 @@ namespace LibGit2Sharp
return match;
}
+
+ /// <summary>
+ /// Determine whether <paramref name="shortSha"/> matches the hexified
+ /// representation of the first nibbles of this instance.
+ /// <para>
+ /// Comparison is made in a case insensitive-manner.
+ /// </para>
+ /// </summary>
+ /// <returns>True if this instance starts with <paramref name="shortSha"/>,
+ /// false otherwise.</returns>
+ public bool StartsWith(string shortSha)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(shortSha, "shortSha");
+
+ return Sha.StartsWith(shortSha, StringComparison.OrdinalIgnoreCase);
+ }
}
}