@matheusbsbs / matheus-bagliano / commits / 4471649f44
Fork 0

contrib/hooks/post-receive-email: Put rev display in separate function

The display of a revision in an email-appropriate format is done in two places with similar code. In preparation for making that display more complex, move it into a separate function that handles both cases. Signed-off-by: Pete Harlan <pgit@pcharlan.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pete Harlan committed Nov 3, 2008 at 23:19 UTC 4471649f44d7a8e4b7b927e43b848bb71b75630d
1 file changed +32 -9
contrib/hooks/post-receive-email
+32 -9
@@ -224,13 +224,7 @@ generate_create_branch_email()
224 echo ""
225
226 echo $LOGBEGIN
227 - # This shows all log entries that are not already covered by
228 - # another ref - i.e. commits that are now accessible from this
229 - # ref that were previously not accessible
230 - # (see generate_update_branch_email for the explanation of this
231 - # command)
232 - git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
233 - git rev-list --pretty --stdin $newrev
227 + show_new_revisions
228 echo $LOGEND
229 }
230
@@ -390,8 +384,7 @@ generate_update_branch_email()
384
385 echo ""
386 echo $LOGBEGIN
393 - git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
394 - git rev-list --pretty --stdin $oldrev..$newrev
387 + show_new_revisions
388
389 # XXX: Need a way of detecting whether git rev-list actually
390 # outputted anything, so that we can issue a "no new
@@ -591,6 +584,36 @@ generate_delete_general_email()
584 echo $LOGEND
585 }
586
587 +
588 +# --------------- Miscellaneous utilities
589 +
590 +#
591 +# Show new revisions as the user would like to see them in the email.
592 +#
593 +show_new_revisions()
594 +{
595 + # This shows all log entries that are not already covered by
596 + # another ref - i.e. commits that are now accessible from this
597 + # ref that were previously not accessible
598 + # (see generate_update_branch_email for the explanation of this
599 + # command)
600 +
601 + # Revision range passed to rev-list differs for new vs. updated
602 + # branches.
603 + if [ "$change_type" = create ]
604 + then
605 + # Show all revisions exclusive to this (new) branch.
606 + revspec=$newrev
607 + else
608 + # Branch update; show revisions not part of $oldrev.
609 + revspec=$oldrev..$newrev
610 + fi
611 +
612 + git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
613 + git rev-list --pretty --stdin $revspec
614 +}
615 +
616 +
617 send_mail()
618 {
619 if [ -n "$envelopesender" ]; then