You may want to use the LibGit2Sharp call and make sure it's actually a valid ref - rather than just checking if it's null or whitespace?