X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=server%2Ffunctions;h=f00dcb9859521d23d409925e835325c667300e76;hb=4aca6f6a15deb23b6c7e58aff25769afbcddc8cd;hp=5040ef70395ac2fae116bd990225945c3b91acfa;hpb=850118b309546059444a9be8b9f032ca8d940354;p=git-central.git diff --git a/server/functions b/server/functions index 5040ef7..f00dcb9 100644 --- a/server/functions +++ b/server/functions @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Sets: new_commits # Assumes: $oldrev $newrev $refname @@ -85,7 +85,7 @@ # "remotes/" will be ignored as well. # ################################################## -function set_new_commits() { +set_new_commits() { nl=$'\n' # Get all the current branches, not'd as we want only new ones @@ -114,7 +114,7 @@ function set_new_commits() { # 0000->1234 (create) # 1234->2345 (update) # 2345->0000 (delete) -function set_change_type() { +set_change_type() { if [ "$oldrev" == "0000000000000000000000000000000000000000" ] ; then change_type="create" else @@ -129,7 +129,7 @@ function set_change_type() { # Sets: $newrev_type $oldrev_type $rev $rev_type # Assumes: $newrev $oldrev # --- Get the revision types -function set_rev_types() { +set_rev_types() { newrev_type=$(git cat-file -t "$newrev" 2> /dev/null) oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null) if [ "$newrev" == "0000000000000000000000000000000000000000" ] ; then @@ -145,7 +145,7 @@ function set_rev_types() { # Assumes: $rev # # The email subject will contain the best description of the ref that we can build from the parameters -function set_describe() { +set_describe() { rev_to_describe="$rev" if [ "$1" != "" ] ; then rev_to_describe="$1" @@ -161,7 +161,7 @@ function set_describe() { # Assumes: $rev # # The email subject will contain the best description of the ref that we can build from the parameters -function set_describe_tags() { +set_describe_tags() { rev_to_describe="$rev" if [ "$1" != "" ] ; then rev_to_describe="$1" @@ -179,34 +179,35 @@ function set_describe_tags() { # # with_lock "foo.lock" "echo a" # Works # with_lock "foo.lock" "echo b1 ; echo b2" # Work -# function several() { +# several() { # echo several1 ; echo several2 # } # with_lock "foo.lock" several # Works # -function with_lock() { +with_lock() { lockfile="$1" block="$2" with_lock_has_lock=1 trap with_lock_unlock_if_held INT TERM EXIT - lockfile -1 -r 300 "$lockfile" + # used to use lockfile to try multiple times but it's not always available + mkdir "$lockfile" with_lock_has_lock=$? if [ $with_lock_has_lock -ne 0 ] ; then exit $? fi eval "$block" - rm -f "$lockfile" + rmdir "$lockfile" with_lock_has_lock=1 } -function with_lock_unlock_if_held() { +with_lock_unlock_if_held() { if [[ "$with_lock_has_lock" -eq 0 ]] ; then rm -f "$lockfile" fi } -function display_error_message() { +display_error_message() { echo "----------------------------------------------------" >&2 echo "" >&2 echo "" >&2