The situation is slightly more complex: Programmers write bad code for many different reasons, but good code only gets written by good programmers. So I think it's fine to judge someone on their commit history, as long as one is understanding of the bad code that inevitably happens. The good code doesn't happen by accident.
I wish I could upvote this more. I guess a corollary would be that if there is some good code in a programmer's history, we can ask "what circumstances made this possible?" and learn how to get the best out of people, rather than looking to find the worst in them.