4 # Assumes: $oldrev $newrev $refname
6 # This is for use in post receive hooks, as it assumes the refname has moved and
7 # is now newrev, we need to discard it. This is down with bash string replace,
8 # as it will replace only the first match, compared to the canonical "grep -v"
9 # approach which will throw out multiple matches if the same commit is referred
10 # to by multiple branches.
11 function set_new_commits() {
14 # Get all the current branches, not'd as we want only new ones
15 new_commits=$(git rev-parse --not --branches)
17 # Strip off the not current branch
18 new_hash=$(git rev-parse $refname)
19 new_commits=${new_commits/^$new_hash/}
21 # Put back newrev without the not
22 new_commits=${new_commits}${nl}${newrev}
24 # Put in ^oldrev if it's not a new branch
25 if [ "$oldrev" != "0000000000000000000000000000000000000000" ] ; then
26 new_commits=${new_commits}${nl}^${oldrev}
29 new_commits=${new_commits/$nl$nl/$nl}
30 new_commits=${new_commits/#$nl/}
34 # Assumes: $oldrev $newrev
40 function set_change_type() {
41 if [ "$oldrev" == "0000000000000000000000000000000000000000" ] ; then
44 if [ "$newrev" == "0000000000000000000000000000000000000000" ] ; then
52 # Sets: $newrev_type $oldrev_type $rev $rev_type
53 # Assumes: $newrev $oldrev
54 # --- Get the revision types
55 function set_rev_types() {
56 newrev_type=$(git cat-file -t "$newrev" 2> /dev/null)
57 oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
58 if [ "$newrev" == "0000000000000000000000000000000000000000" ] ; then
59 rev_type="$oldrev_type"
62 rev_type="$newrev_type"
70 # The email subject will contain the best description of the ref that we can build from the parameters
71 function set_describe() {
72 describe=$(git describe $rev 2>/dev/null)
73 if [ -z "$describe" ]; then