]> Nutra Git (v1) - gamesguru/git-remote-gcrypt.git/commitdiff
Put the main loop for the git protocol in a function
authorroot <root@localhost>
Mon, 7 Jan 2013 01:20:39 +0000 (18:20 -0700)
committerroot <root@localhost>
Mon, 7 Jan 2013 01:20:39 +0000 (18:20 -0700)
git-remote-gcrypt

index 73f75e2b81708f5a5149714fe0841d1e861383fa..e12d3551cb85381e884f1360c4801774a386f5b3 100755 (executable)
@@ -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 "$@"