Petit, who has seen limited action in six major league seasons, narrowly missed baseball history by retiring the first 26 batters he faced.
Eric Chavez ended the spectacular show, however, by sending a looping liner to right on a 3-2 pitch. Right fielder Hunter Pence made a diving attempt to grab the ball, but it short hopped into his glove for a single.
Petit (3-0) then retired A.J. Pollock on a grounder to third to end the game and pick up his first shutout in 40 career starts. Petit struck out seven in what was only his third start of the season.
Pence scored San Francisco's first two runs run on a fielding error in the second and a single by Hector Sanchez in the fourth. Pence hit a solo homer in the eighth to complete the scoring.
Patrick Corbin (13-6) went the distance in taking the loss, giving up eight hits and striking out five.
Celebrity Families of 2014 [PHOTOS]