Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'henon/master'

  • Loading branch information...
commit bb21f1716657cf4aebf0015d19e2cc51eeb6307c 2 parents 1a0fa3e + e653964
@nulltoken nulltoken authored
View
1  Git/Init.cs
@@ -67,6 +67,7 @@ public override void Run(string[] args)
{
List<String> arguments = ParseOptions(args);
cmd.Execute();
+ cmd.OutputStream.WriteLine(cmd.Repository.Directory);
}
catch (Exception e)
{
View
2  GitSharp/Commands/InitCommand.cs
@@ -129,7 +129,7 @@ public override void Execute()
OutputStream.WriteLine(String.Format("{0} empty Git repository in {1}", reinit ? "Reinitialized" : "Initialized", repo.Directory.FullName));
OutputStream.Flush();
}
- Repository = new Repository(repo.Directory.FullName);
+ Repository = new Repository(repo);
}
}
}
View
59 GitSharp/Commit.cs
@@ -39,6 +39,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using GitSharp.Core.RevWalk;
using GitSharp.Core.Util;
using ObjectId = GitSharp.Core.ObjectId;
@@ -264,42 +265,44 @@ public Tree Tree
}
/// <summary>
- /// Returns all ancestor-commits of this commit.
- /// Be careful, in a big repository this can be quite a long list and you might go out of memory. Use for small repo's only.
- ///
- /// Todo: reimplement this with an iterator instead of recursion.
+ /// Returns an iterator over all ancestor-commits of this commit.
/// </summary>
public IEnumerable<Commit> Ancestors
{
get
{
- return GetAncestorIds(this);
+ var revwalk = new RevWalk(_repo);
+ revwalk.RevSortStrategy.Add(RevSort.Strategy.COMMIT_TIME_DESC);
+ revwalk.RevSortStrategy.Add(RevSort.Strategy.TOPO);
+ revwalk.markStart(revwalk.parseCommit(_id));
+ foreach(var revcommit in revwalk)
+ yield return new Commit(_repo, revcommit.AsCommit(revwalk));
}
}
- private static IList<Commit> GetAncestorIds(Commit commit)
- {
- Stack<Commit> ancestorsStack = new Stack<Commit>();
- Dictionary<ObjectId, Commit> ancestors = new Dictionary<ObjectId, Commit>();
-
- ancestorsStack.Push(commit);
-
- while (ancestorsStack.Count > 0)
- {
- Commit currentCommit = ancestorsStack.Pop();
- var parentCommits = currentCommit.InternalCommit.ParentIds
- .Where(id => !ancestors.ContainsKey(id))
- .Select(id => new Commit(commit._repo, id));
-
- foreach (Commit parentCommit in parentCommits)
- {
- ancestorsStack.Push(parentCommit);
- ancestors[parentCommit._id] = parentCommit;
- }
- }
-
- return ancestors.Values.ToList();
- }
+ //private static IList<Commit> GetAncestorIds(Commit commit)
+ //{
+ // Stack<Commit> ancestorsStack = new Stack<Commit>();
+ // Dictionary<ObjectId, Commit> ancestors = new Dictionary<ObjectId, Commit>();
+
+ // ancestorsStack.Push(commit);
+
+ // while (ancestorsStack.Count > 0)
+ // {
+ // Commit currentCommit = ancestorsStack.Pop();
+ // var parentCommits = currentCommit.InternalCommit.ParentIds
+ // .Where(id => !ancestors.ContainsKey(id))
+ // .Select(id => new Commit(commit._repo, id));
+
+ // foreach (Commit parentCommit in parentCommits)
+ // {
+ // ancestorsStack.Push(parentCommit);
+ // ancestors[parentCommit._id] = parentCommit;
+ // }
+ // }
+
+ // return ancestors.Values.ToList();
+ //}
/// <summary>
/// Checkout this commit into the repositorie's working directory. Does not reset HEAD.
Please sign in to comment.
Something went wrong with that request. Please try again.