ATLANTA -- Matt Cain snapped his three-game losing streak with five-hit ball over eight innings, and the San Francisco Giants barely avoided another loss to Atlanta in the final at-bat, holding on for a 7-5 victory over the Braves on Wednesday night.