Walk the MERGE_HEAD file with a function.
auto repo = initRepo(_userRepo, OpenBare.yes); scope(exit) rmdirRecurse(_userRepo); string[] mergeHeadItems = [ "e496660174425e3147a0593ced2954f3ddbf65ca\n", "e496660174425e3147a0593ced2954f3ddbf65ca\n" ]; std.file.write(buildPath(repo.path, "MERGE_HEAD"), mergeHeadItems.join()); static ContinueWalk walkFunc(GitOid oid) { static int count; count++; assert(count != 2); // we're stopping after the first iteration assert(oid == GitOid("e496660174425e3147a0593ced2954f3ddbf65ca")); return ContinueWalk.no; } repo.walkMergeHead(&walkFunc);
Walk the MERGE_HEAD file with a delegate.
auto repo = initRepo(_userRepo, OpenBare.yes); scope(exit) rmdirRecurse(_userRepo); string[] mergeHeadItems = [ "e496660174425e3147a0593ced2954f3ddbf65ca\n", "e496660174425e3147a0593ced2954f3ddbf65ca\n" ]; std.file.write(buildPath(repo.path, "MERGE_HEAD"), mergeHeadItems.join()); struct S { size_t count; // delegate walker ContinueWalk walker(GitOid oid) { string line = mergeHeadItems[count++]; string commitHex = line.split[0]; assert(oid == GitOid(commitHex)); return ContinueWalk.yes; } ~this() { assert(count == 2); // verify we've walked through all the items } } S s; repo.walkMergeHead(&s.walker);
Call the callback function for each entry in the MERGE_HEAD file in this repository.
The callback type must be either MergeHeadFunction or MergeHeadDelegate.
This function will return when either all entries are exhausted or when the callback returns ContinueWalk.no.