Skip to content

Commit

Permalink
Fix contrib/hooks/post-receive-email for new duplicate branch
Browse files Browse the repository at this point in the history
In the show_new_revisions function, the original code:

  git rev-parse --not --branches | grep -v $(git rev-parse $refname) |

isn't quite right since one can create a new branch and push it
without any new commits.  In that case, two refs will have the same
sha1 but both would get filtered by the 'grep'.  In the end, we'll
show ALL the history which is not what we want.  Instead, we should
list the branches by name and remove the branch being updated and THEN
pass that list through rev-parse.

Revised as suggested by Jakub Narebski and Junio C Hamano to use
git-for-each-ref instead of git-branch.  (Thanks!)

Signed-off-by: Pat Notz <pknotz@sandia.gov>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Pat Notz authored and Junio C Hamano committed Feb 11, 2009
1 parent 7b73d82 commit e5f5050
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contrib/hooks/post-receive-email
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,9 @@ show_new_revisions()
revspec=$oldrev..$newrev
fi

git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
other_branches=$(git for-each-ref --format='%(refname)' refs/heads/ |
grep -F -v $refname)
git rev-parse --not $other_branches |
if [ -z "$custom_showrev" ]
then
git rev-list --pretty --stdin $revspec
Expand Down

0 comments on commit e5f5050

Please sign in to comment.