GitRepo.walkMergeHead

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.

  1. void walkMergeHead(MergeHeadFunction callback)
  2. void walkMergeHead(scope MergeHeadDelegate callback)
    struct GitRepo
    void
    walkMergeHead
  3. auto walkMergeHead()

Examples

Walk the MERGE_HEAD file with a function.

1 auto repo = initRepo(_userRepo, OpenBare.yes);
2 scope(exit) rmdirRecurse(_userRepo);
3 
4 string[] mergeHeadItems = [
5     "e496660174425e3147a0593ced2954f3ddbf65ca\n",
6     "e496660174425e3147a0593ced2954f3ddbf65ca\n"
7 ];
8 
9 std.file.write(buildPath(repo.path, "MERGE_HEAD"), mergeHeadItems.join());
10 
11 static ContinueWalk walkFunc(GitOid oid)
12 {
13     static int count;
14     count++;
15 
16     assert(count != 2);  // we're stopping after the first iteration
17 
18     assert(oid == GitOid("e496660174425e3147a0593ced2954f3ddbf65ca"));
19 
20     return ContinueWalk.no;
21 }
22 
23 repo.walkMergeHead(&walkFunc);

Walk the MERGE_HEAD file with a delegate.

1 auto repo = initRepo(_userRepo, OpenBare.yes);
2 scope(exit) rmdirRecurse(_userRepo);
3 
4 string[] mergeHeadItems = [
5     "e496660174425e3147a0593ced2954f3ddbf65ca\n",
6     "e496660174425e3147a0593ced2954f3ddbf65ca\n"
7 ];
8 
9 std.file.write(buildPath(repo.path, "MERGE_HEAD"), mergeHeadItems.join());
10 
11 struct S
12 {
13     size_t count;
14 
15     // delegate walker
16     ContinueWalk walker(GitOid oid)
17     {
18         string line = mergeHeadItems[count++];
19         string commitHex = line.split[0];
20         assert(oid == GitOid(commitHex));
21 
22         return ContinueWalk.yes;
23     }
24 
25     ~this()
26     {
27         assert(count == 2);  // verify we've walked through all the items
28     }
29 }
30 
31 S s;
32 repo.walkMergeHead(&s.walker);

Meta