4 # Assumes: $oldrev, $newrev, and $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/}