Skip to content

Commit cdb48ec

Browse files
committed
Checkout the HEAD after creating test commits
This ensure the working copy is in a sane state for subsequent tests
1 parent 09250d2 commit cdb48ec

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ObjectiveGitTests/GTUtilityFunctions.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
GTCommit *testCommit = [repo createCommitWithTree:testTree message:message parents:@[ parent ] updatingReferenceNamed:headReference.name error:nil];
3535
expect(testCommit).notTo(beNil());
3636

37+
if (!repo.isBare) {
38+
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
39+
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
40+
int gitError = git_checkout_head(repo.git_repository, &opts);
41+
expect(gitError).to(equal(0));
42+
}
43+
3744
return testCommit;
3845
};
3946

0 commit comments

Comments
 (0)