maintner: fix infinite loop bug in GitCommit.HasAncestor

Fix a stupid bug fortunately found before production.

Add the test that caught it.

Updates golang/go#20222

Change-Id: Ie988d80dec18e5d0fede7a31e3b6cce62b050f5f
Reviewed-on: https://go-review.googlesource.com/43555
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2 files changed