Skip to content

Commit e5f5050

Browse files
Pat Notzgitster
authored andcommitted
Fix contrib/hooks/post-receive-email for new duplicate branch
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7b73d82 commit e5f5050

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

contrib/hooks/post-receive-email

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,9 @@ show_new_revisions()
615615
revspec=$oldrev..$newrev
616616
fi
617617

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

0 commit comments

Comments
 (0)