As you do not assert below which commit the detached Head points to, you may be willing to replace the three lines above with

```
cl_git_pass(git_repository_detach_head(repo));
```

Of course, a more thorough option would be to verify that Head indeed points to the same commit oid ;-)