Gaurav Shah
unread,Jun 21, 2011, 4:26:19 PM6/21/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gits...@googlegroups.com
Hi Folks,
I am creating a branch and cherry-picking commits which satisfy certain condition. I am looping through all commits and reading commit affected files to check if it satisfies a condition. For that I need to checkout commits. For some commits , when I am reading the affected files, somehow they get modified and while checking out next commit it throws an exception. I tried to reset the branch but in vain. Here is the sample code. Any suggestions??
public List<Commit> GetCommits(string keyword, Repository repo)
{
List<Commit> commitList = new List<Commit>();
foreach (KeyValuePair<string, GitSharp.Branch> kvp in repo.Branches)
{
foreach (var commit in kvp.Value.CurrentCommit.Ancestors)
{
kvp.Value.Reset(ResetBehavior.Hard);
commit.Checkout();
foreach (Change c in commit.Changes)
{
if (c.ChangeType != ChangeType.Deleted)
{
FileInfo file = new FileInfo(workingDir + "/" + c.Path);
if (ReadFile(file, keyword))
{
break;
}
}
}
}
}
return commitList;
}
FIGHT 2 LIVE & LIVE 2 WIN