From cd90cea0fe72e6bb1a8f2992b642b28398111ebb Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jan 2013 18:20:39 -0700 Subject: Put the main loop for the git protocol in a function --- git-remote-gcrypt | 112 +++++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 52 deletions(-) (limited to 'git-remote-gcrypt') diff --git a/git-remote-gcrypt b/git-remote-gcrypt index 73f75e2..e12d355 100755 --- a/git-remote-gcrypt +++ b/git-remote-gcrypt @@ -762,59 +762,67 @@ cleanup_atexit() rm -f "$Localdir"/tmp_*".$$" >&2 } -NAME=$1 # Remote name -URL=$2 # Remote URL - -mkdir -p "$Localdir" -trap cleanup_atexit EXIT 1 2 3 15 - -echo_info "Development version -- Repository format MAY CHANGE" - -while read Input -do - case "$Input" in - capabilities) - do_capabilities - ;; - list|list\ for-push) - do_list - ;; - fetch\ *) - args_="${Input##fetch }" - while read InputX - do - case "$InputX" in - fetch*) - args_= #ignored +# handle git-remote-helpers protocol +gcrypt_main_loop() +{ + local input_= input_inner= args_= + + NAME=$1 # Remote name + URL=$2 # Remote URL + + mkdir -p "$Localdir" + trap cleanup_atexit EXIT 1 2 3 15 + + echo_info "Development version -- Repository format MAY CHANGE" + + while read input_ + do + case "$input_" in + capabilities) + do_capabilities ;; - *) - break + list|list\ for-push) + do_list ;; - esac - done - do_fetch "$args_" - ;; - push\ *) - args_="${Input##push }" - while read InputX - do - case "$InputX" in - push\ *) - append_to args_ "${InputX#push }" - ;; - *) + fetch\ *) + args_="${input_##fetch }" + while read input_inner + do + case "$input_inner" in + fetch*) + args_= #ignored + ;; + *) break + ;; + esac + done + do_fetch "$args_" ;; - esac - done - do_push "$args_" - ;; - ?*) - echo_die "Unknown input!" - ;; - *) - CLEAN_FINAL "$URL" - exit 0 - ;; - esac -done + push\ *) + args_="${input_##push }" + while read input_inner + do + case "$input_inner" in + push\ *) + append_to args_ "${input_inner#push }" + ;; + *) + break + ;; + esac + done + do_push "$args_" + ;; + ?*) + echo_die "Unknown input!" + ;; + *) + CLEAN_FINAL "$URL" + exit 0 + ;; + esac + done +} + +gcrypt_main_loop "$@" -- cgit v1.2.3