From 25905b24e3860f1122dbc93bbcec6cf8274adab6 Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Sat, 27 Jun 2009 10:32:00 -0400 Subject: [PATCH] gnome-post-receive-email: Handle initial push Commit fe7b408 (Don't show commits since the beginning of time for branch creation) introduced a check which uses the parent of the first commit we're interested in showing. If this hook is enabled when the initial push is made to the repository, that commit has no parent and the call to git rev-list yields an error (and 128 return code). This prevents that by checking that the parent of first_detailed_commit is a valid ref before using it. --- gnome-post-receive-email | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gnome-post-receive-email b/gnome-post-receive-email index d670b74..d614d01 100755 --- a/gnome-post-receive-email +++ b/gnome-post-receive-email @@ -245,9 +245,15 @@ class BranchChange(RefChange): # branch creation was processed first. # if len(detailed_commits) > 0: - first_detailed_commit = detailed_commits[-1] - self.added_commits = rev_list_commits(first_detailed_commit + "^.." + self.newrev) - self.added_commits.reverse() + # Verify parent of first detailed commit is valid. On initial push, it is not. + parent = detailed_commits[-1] + "^" + try: + validref = git.rev_parse(parent, _quiet=True) + except CalledProcessError: + self.added_commits = [] + else: + self.added_commits = rev_list_commits(parent + ".." + self.newrev) + self.added_commits.reverse() else: self.added_commits = [] self.removed_commits = [] -- 1.6.3.3