{"thread":{"id":"17704","subject":"[PATCH] Fix contrib/hooks/post-receive-email for new duplicate branch","startedAt":"2009-02-10T16:18:27Z","lastAt":"2009-02-10T16:18:27Z","messageCount":1,"participants":["Pat Notz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"104032","messageId":"1234282707-6295-1-git-send-email-pknotz@sandia.gov","threadId":"17704","inReplyTo":null,"subject":"[PATCH] Fix contrib/hooks/post-receive-email for new duplicate branch","fromName":"Pat Notz","fromEmail":"pknotz@sandia.gov","sentAt":"2009-02-10T16:18:27Z","receivedAt":"2009-02-10T16:18:27Z","isPatch":true,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"In the show_new_revisions function, the original code:\n\n  git rev-parse --not --branches | grep -v $(git rev-parse $refname) |\n\nisn't quite right since one can create a new branch and push it\nwithout any new commits.  In that case, two refs will have the same\nsha1 but both would get filtered by the 'grep'.  In the end, we'll\nshow ALL the history which is not what we want.  Instead, we should\nlist the branches by name and remove the branch being updated and THEN\npass that list through rev-parse.\n\nRevised as suggested by Jakub Narebski <jnareb@gmail.com> to use\ngit-for-each-ref instead of git-branch.  (Thanks!)\n\nSigned-off-by: Pat Notz <pknotz@sandia.gov>\n---\n contrib/hooks/post-receive-email |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 28a3c0e..ec52751 100644\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -615,7 +615,9 @@ show_new_revisions()\n \t\trevspec=$oldrev..$newrev\n \tfi\n \n-\tgit rev-parse --not --branches | grep -v $(git rev-parse $refname) |\n+\tother_branches=$(git for-each-ref --format='%(refname)' refs/heads/ |\n+\t    grep -v $refname)\n+\tgit rev-parse --not $other_branches |\n \tif [ -z \"$custom_showrev\" ]\n \tthen\n \t\tgit rev-list --pretty --stdin $revspec\n-- \n1.6.1.2\n"}]}