Skip to content

Commit

Permalink
henon entered the plan. i will "fast forward" the development speed
Browse files Browse the repository at this point in the history
* Gitty.Core is now a "real" standalone project (git-sharp) and got its own solution.
* added testgui that can execute the unit tests. cool for debugging!!!
* ported a lot of unit tests and a lot of code to get them working
* fixed some errors in the existing ported code
* ... and had a lot of fun ;)

Signed-off-by: henon <meinrad.recheis@gmail.com>
  • Loading branch information
henon committed Jun 13, 2009
1 parent f42efb8 commit 92300d8
Show file tree
Hide file tree
Showing 60 changed files with 7,604 additions and 99 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ bin
obj
*.user
*.suo
*.bak
8 changes: 5 additions & 3 deletions AnyObjectId.cs
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* Copyright (C) 2008, Kevin Thompson <kevin.thompson@theautomaters.com>
* Copyright (C) 2009, Henon <meinrad.recheis@gmail.com>
*
* All rights reserved.
*
Expand Down Expand Up @@ -59,7 +60,7 @@ internal class Constants
public static readonly int StringLength = ObjectIdLength * 2;
}


public static bool operator ==(AnyObjectId a, AnyObjectId b)
{
if ((object)a == null)
Expand All @@ -81,7 +82,7 @@ internal class Constants

public virtual bool Equals(AnyObjectId obj)
{
return (obj != null) ? Equals(this, obj) : false;
return (obj != null) ? this == obj : false;
}

public override bool Equals(object obj)
Expand Down Expand Up @@ -231,7 +232,8 @@ public override string ToString()
return new string(ToHexCharArray());
}

public ObjectId Copy() {
public ObjectId Copy()
{
if (this.GetType() == typeof(ObjectId))
return (ObjectId)this;
return new ObjectId(this);
Expand Down
80 changes: 51 additions & 29 deletions Commit.cs
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
* Copyright (C) 2008, Kevin Thompson <kevin.thompson@theautomaters.com>
* Copyright (C) 2009, Henon <meinrad.recheis@gmail.com>
*
* All rights reserved.
*
Expand Down Expand Up @@ -139,38 +140,38 @@ public Commit(Repository db, ObjectId id, byte[] raw)
private ObjectId treeId;

public ObjectId TreeId
{
get
{
return treeId;
}
set
{
if (treeId == null || !treeId.Equals(value))
{
treeEntry = null;
}
treeId = value;
{
get
{
return treeId;
}
}

set
{
if (treeId == null || !treeId.Equals(value))
{
treeEntry = null;
}
treeId = value;
}
}

private Tree treeEntry;
public Tree TreeEntry
{
get
{
if (treeEntry == null)
{
treeEntry = Repository.MapTree(this.TreeId);
if (treeEntry == null)
throw new MissingObjectException(this.TreeId, ObjectType.Tree);
}
return treeEntry;
}
set
{
treeId = value.TreeId;
treeEntry = value;
{
get
{
if (treeEntry == null)
{
treeEntry = Repository.MapTree(this.TreeId);
if (treeEntry == null)
throw new MissingObjectException(this.TreeId, ObjectType.Tree);
}
return treeEntry;
}
set
{
treeId = value.TreeId;
treeEntry = value;
}
}

Expand All @@ -181,6 +182,27 @@ public Tree TreeEntry
public Encoding Encoding { get; set; }
public Repository Repository { get; protected set; }

// Returns all ancestor-commits of this commit
public IEnumerable<Commit> Ancestors
{
get
{
var ancestors = new Dictionary<ObjectId, Commit>();
CollectAncestorIdsRecursive(this, ancestors);
return ancestors.Values.ToArray();
}
}

private static void CollectAncestorIdsRecursive(Commit commit, Dictionary<ObjectId,Commit> ancestors)
{
foreach (var parent in commit.ParentIds.Where(id => !ancestors.ContainsKey(id)).Select(id => commit.Repository.OpenCommit(id)))
{
var parent_commit = parent as Commit;
ancestors[parent_commit.CommitId] = parent_commit;
CollectAncestorIdsRecursive(parent_commit, ancestors);
}
}

private string message;
public string Message
{
Expand Down

0 comments on commit 92300d8

Please sign in to comment.