Skip to content
Browse files

Use implicit GitOid to ObjectId cast everywhere

  • Loading branch information...
1 parent 09beddc commit 82a86f28ca946d123a3e2609abf07feb9d241fe3 @dahlbyk dahlbyk committed with nulltoken Feb 28, 2013
View
22 LibGit2Sharp/Core/Proxy.cs
@@ -45,7 +45,7 @@ public static ObjectId git_blob_create_fromchunks(RepositorySafeHandle repo, Fil
int res = NativeMethods.git_blob_create_fromchunks(ref oid, repo, hintpath, fileCallback, IntPtr.Zero);
Ensure.ZeroResult(res);
- return new ObjectId(oid);
+ return oid;
}
}
@@ -57,7 +57,7 @@ public static ObjectId git_blob_create_fromdisk(RepositorySafeHandle repo, FileP
int res = NativeMethods.git_blob_create_fromdisk(ref oid, repo, path);
Ensure.ZeroResult(res);
- return new ObjectId(oid);
+ return oid;
}
}
@@ -69,7 +69,7 @@ public static ObjectId git_blob_create_fromfile(RepositorySafeHandle repo, FileP
int res = NativeMethods.git_blob_create_fromworkdir(ref oid, repo, path);
Ensure.ZeroResult(res);
- return new ObjectId(oid);
+ return oid;
}
}
@@ -265,7 +265,7 @@ public static Signature git_commit_committer(GitObjectSafeHandle obj)
committerHandle, encoding, prettifiedMessage, treePtr.ObjectPtr, parentObjectPtrs.Count, parentsPtrs);
Ensure.ZeroResult(res);
- return new ObjectId(commitOid);
+ return commitOid;
}
}
@@ -769,7 +769,7 @@ public static void git_index_write(IndexSafeHandle index)
}
}
- public static GitOid git_tree_create_fromindex(Index index)
+ public static ObjectId git_tree_create_fromindex(Index index)
{
using (ThreadAffinity())
{
@@ -801,7 +801,7 @@ public static ObjectId git_merge_base(RepositorySafeHandle repo, Commit first, C
Ensure.ZeroResult(res);
- return new ObjectId(ret);
+ return ret;
}
}
@@ -848,7 +848,7 @@ public static string git_message_prettify(string message)
int res = NativeMethods.git_note_create(out noteOid, repo, authorHandle, committerHandle, notes_ref, ref oid, note, force ? 1 : 0);
Ensure.ZeroResult(res);
- return new ObjectId(noteOid);
+ return noteOid;
}
}
@@ -1699,7 +1699,7 @@ public static ObjectId git_revwalk_next(RevWalkerSafeHandle walker)
Ensure.ZeroResult(res);
- return new ObjectId(ret);
+ return ret;
}
}
@@ -1837,7 +1837,7 @@ public static ICollection<TResult> git_status_foreach<TResult>(RepositorySafeHan
int res = NativeMethods.git_tag_create(out oid, repo, name, objectPtr.ObjectPtr, taggerHandle, message, allowOverwrite);
Ensure.ZeroResult(res);
- return new ObjectId(oid);
+ return oid;
}
}
@@ -1850,7 +1850,7 @@ public static ObjectId git_tag_create_lightweight(RepositorySafeHandle repo, str
int res = NativeMethods.git_tag_create_lightweight(out oid, repo, name, objectPtr.ObjectPtr, allowOverwrite);
Ensure.ZeroResult(res);
- return new ObjectId(oid);
+ return oid;
}
}
@@ -1997,7 +1997,7 @@ public static ObjectId git_treebuilder_write(RepositorySafeHandle repo, TreeBuil
int res = NativeMethods.git_treebuilder_write(out oid, repo, bld);
Ensure.ZeroResult(res);
- return new ObjectId(oid);
+ return oid;
}
}
View
2 LibGit2Sharp/IndexEntry.cs
@@ -61,7 +61,7 @@ internal static IndexEntry BuildFromPtr(Repository repo, IndexEntrySafeHandle ha
return new IndexEntry
{
Path = path.Native,
- Id = new ObjectId(entry.oid),
+ Id = entry.oid,
state = () => repo.Index.RetrieveStatus(path.Native),
StageLevel = Proxy.git_index_entry_stage(handle),
Mode = (Mode)entry.Mode
View
4 LibGit2Sharp/Network.cs
@@ -40,7 +40,7 @@ public virtual IEnumerable<FetchHead> FetchHeads
return Proxy.git_repository_fetchhead_foreach(
repository.Handle,
- (name, url, oid, isMerge) => new FetchHead(repository, name, url, new ObjectId(oid), isMerge, i++));
+ (name, url, oid, isMerge) => new FetchHead(repository, name, url, oid, isMerge, i++));
}
}
@@ -76,7 +76,7 @@ public virtual IEnumerable<DirectReference> ListReferences(Remote remote)
return -1;
}
- ObjectId oid = new ObjectId(remoteHead.Oid);
+ ObjectId oid = remoteHead.Oid;
string name = Utf8Marshaler.FromNative(remoteHead.NamePtr);
directReferences.Add(new DirectReference(name, this.repository, oid));
View
2 LibGit2Sharp/NoteCollection.cs
@@ -114,7 +114,7 @@ where refCanonical.StartsWith(refsNotesPrefix, StringComparison.Ordinal) && refC
string canonicalNamespace = NormalizeToCanonicalName(@namespace);
return Proxy.git_note_foreach(repo.Handle, canonicalNamespace,
- (blobId,annotatedObjId) => RetrieveNote(new ObjectId(annotatedObjId), canonicalNamespace));
+ (blobId,annotatedObjId) => RetrieveNote(annotatedObjId, canonicalNamespace));
}
}
View
2 LibGit2Sharp/RemoteCallbacks.cs
@@ -99,7 +99,7 @@ private int GitUpdateTipsHandler(IntPtr str, ref GitOid oldId, ref GitOid newId,
if (onUpdateTips != null)
{
string refName = Utf8Marshaler.FromNative(str);
- result = onUpdateTips(refName, new ObjectId(oldId), new ObjectId(newId));
+ result = onUpdateTips(refName, oldId, newId);
}
return result;
View
6 LibGit2Sharp/Repository.cs
@@ -672,8 +672,8 @@ public Commit Commit(string message, Signature author, Signature committer, bool
throw new LibGit2SharpException("Can not amend anything. The Head doesn't point at any commit.");
}
- GitOid treeOid = Proxy.git_tree_create_fromindex(Index);
- var tree = this.Lookup<Tree>(new ObjectId(treeOid));
+ var treeId = Proxy.git_tree_create_fromindex(Index);
+ var tree = this.Lookup<Tree>(treeId);
var parents = RetrieveParentsOfTheCommitBeingCreated(amendPreviousCommit);
@@ -784,7 +784,7 @@ public virtual IEnumerable<MergeHead> MergeHeads
{
int i = 0;
return Proxy.git_repository_mergehead_foreach(Handle,
- commitId => new MergeHead(this, new ObjectId(commitId), i++));
+ commitId => new MergeHead(this, commitId, i++));
}
}
View
4 LibGit2Sharp/TreeChanges.cs
@@ -95,8 +95,8 @@ private TreeEntryChanges AddFileChange(GitDiffDelta delta, GitDiffLineOrigin lin
var oldFilePath = FilePathMarshaler.FromNative(delta.OldFile.Path);
var newMode = (Mode)delta.NewFile.Mode;
var oldMode = (Mode)delta.OldFile.Mode;
- var newOid = new ObjectId(delta.NewFile.Oid);
- var oldOid = new ObjectId(delta.OldFile.Oid);
+ var newOid = delta.NewFile.Oid;
+ var oldOid = delta.OldFile.Oid;
if (delta.Status == ChangeKind.Untracked)
{

0 comments on commit 82a86f2

Please sign in to comment.
Something went wrong with that request. Please try again.