 	///
 	/// Returns the commit if it exists, or an error.
 	public func commitWithOID(oid: OID) -> Result<Commit> {
-		let pointer = UnsafeMutablePointer<COpaquePointer>.alloc(1)
-		let repository = self.pointer
-		var oid = oid.oid
-		let result = git_object_lookup(pointer, repository, &oid, GIT_OBJ_COMMIT)
-		
-		if result < GIT_OK.value {
-			pointer.dealloc(1)
-			return failure()
-		}
-		
-		let commit = Commit(pointer.memory)
-		git_object_free(pointer.memory)
-		pointer.dealloc(1)
-		return success(commit)
+		return self.withLibgit2Object(oid, type: GIT_OBJ_COMMIT) { Commit($0) }
 	}
 	
 	/// Loads the tag with the given OID.

	///
	/// Returns the tree if it exists, or an error.
	public func treeWithOID(oid: OID) -> Result<Tree> {
		let pointer = UnsafeMutablePointer<COpaquePointer>.alloc(1)
		let repository = self.pointer
		var oid = oid.oid
		let result = git_object_lookup(pointer, repository, &oid, GIT_OBJ_TREE)
		
		if result < GIT_OK.value {
			pointer.dealloc(1)
			return failure()
		}
		
		let tree = Tree(pointer.memory)
		git_object_free(pointer.memory)
		pointer.dealloc(1)
		return success(tree)
	}
}

	///
	/// Returns the tag if it exists, or an error.
	public func tagWithOID(oid: OID) -> Result<Tag> {
		return self.withLibgit2Object(oid, type: GIT_OBJ_TAG) { Tag($0) }
	}
	
	/// Loads the tree with the given OID.
