GitRepo.walkMergeHead

Walk the MERGE_HEAD file in a foreach loop.

Examples

Walk the MERGE_HEAD using a foreach loop.

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 size_t count;
12 foreach (oid; repo.walkMergeHead)
13 {
14     string line = mergeHeadItems[count++];
15     string commitHex = line.split[0];
16     assert(oid == GitOid(commitHex));
17 }
18 
19 // ensure we've iterated all itmes
20 assert(count == 2);
21 
22 count = 0;
23 foreach (oid; repo.walkMergeHead)
24 {
25     string line = mergeHeadItems[count++];
26     string commitHex = line.split[0];
27     assert(oid == GitOid(commitHex));
28     break;
29 }
30 
31 // ensure 'break' works
32 assert(count == 1);

Meta