Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Build fix #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
5 commits merged into from
Mar 9, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions LibGit2Sharp.Core/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,13 @@ public RawObject ReadHeader(ObjectId id)
GitError.Check(ret);
return new RawObject(ro);
}

public RawObject Read(ObjectId id)
{
git_rawobj ro = new git_rawobj();
int ret = NativeMethods.git_odb_read(&ro, database, &id.oid);
GitError.Check(ret);
return new RawObject(ro);
}
}
}
3 changes: 3 additions & 0 deletions LibGit2Sharp.Core/RawObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public git_otype Type

public byte[] GetData()
{
if (rawobj.data == IntPtr.Zero)
return null;

byte[] rawData = new byte[Length];
Marshal.Copy(rawobj.data, rawData, 0, (int)Length);
return rawData;
Expand Down
24 changes: 24 additions & 0 deletions LibGit2Sharp.Core/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,30 @@ public Database Database
return new Database(NativeMethods.git_repository_database(repository));
}
}

public ObjectId HeadObjectId
{
get {
return ReferenceLookup("HEAD").Resolve().ObjectId;
}
}

public GitObject GetHead()
{
return Lookup(HeadObjectId);
}

public T GetHead<T>() where T : GitObject
{
return Lookup<T>(HeadObjectId);
}

public Commit Head
{
get {
return GetHead<Commit>();
}
}

#region IDisposable implementation
public void Dispose()
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 9 additions & 2 deletions LibGit2Sharp/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Header ReadHeader(string objectId)
return new Header(objectId, (ObjectType)rawObj.Type, rawObj.Length);
};

return ReadInternal(objectId, builder);
return ReadHeaderInternal(objectId, builder);
}

public RawObject Read(string objectId)
Expand All @@ -91,9 +91,16 @@ public bool Exists(string objectId)
return _lifecycleManager.CoreRepository.Database.Exists(new Core.ObjectId(objectId));
}

private TType ReadInternal<TType>(string objectid, Func<Core.RawObject, TType> builder)
private TType ReadHeaderInternal<TType>(string objectid, Func<Core.RawObject, TType> builder)
{
var rawObj = _lifecycleManager.CoreRepository.Database.ReadHeader(new Core.ObjectId(objectid));

return builder(rawObj);
}

private TType ReadInternal<TType>(string objectid, Func<Core.RawObject, TType> builder)
{
var rawObj = _lifecycleManager.CoreRepository.Database.Read(new Core.ObjectId(objectid));

return builder(rawObj);
}
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ NativeMethods.cs for LibGit2.Core. You can do it via the command line:

Or just use "Run this item" from your IDE.

Coding Guidelines
=================

We are using the default Microsoft/MSDN guidlines for coding.
Please don't forget that our tab consists of 4 spaces and every
text file should have a new line at the ending.
The later rule makes it easier for patch tools used by vanilla
git to retrieve patch hunks.

Authors
=======

Expand Down